Merge branch 'dev' into refactor/linting
This commit is contained in:
commit
588c556949
37 changed files with 686 additions and 796 deletions
10
backend/src/exceptions/bad-request-exception.ts
Normal file
10
backend/src/exceptions/bad-request-exception.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { ExceptionWithHttpState } from './exception-with-http-state.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 400 Bad Request
|
||||
*/
|
||||
export class BadRequestException extends ExceptionWithHttpState {
|
||||
constructor(error: string) {
|
||||
super(400, error);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
import { HttpException } from './httpException.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 400 Bad Request
|
||||
*/
|
||||
|
||||
export class BadRequestException extends HttpException {
|
||||
constructor(message = 'Bad Request') {
|
||||
super(400, message);
|
||||
}
|
||||
}
|
12
backend/src/exceptions/conflict-exception.ts
Normal file
12
backend/src/exceptions/conflict-exception.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { ExceptionWithHttpState } from './exception-with-http-state.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 409 Conflict
|
||||
*/
|
||||
export class ConflictException extends ExceptionWithHttpState {
|
||||
public status = 409;
|
||||
|
||||
constructor(error: string) {
|
||||
super(409, error);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import { ConflictException } from './conflict-exception.js';
|
||||
|
||||
export class EntityAlreadyExistsException extends ConflictException {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
}
|
||||
}
|
11
backend/src/exceptions/exception-with-http-state.ts
Normal file
11
backend/src/exceptions/exception-with-http-state.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Exceptions which are associated with a HTTP error code.
|
||||
*/
|
||||
export abstract class ExceptionWithHttpState extends Error {
|
||||
constructor(
|
||||
public status: number,
|
||||
public error: string
|
||||
) {
|
||||
super(error);
|
||||
}
|
||||
}
|
12
backend/src/exceptions/forbidden-exception.ts
Normal file
12
backend/src/exceptions/forbidden-exception.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { ExceptionWithHttpState } from './exception-with-http-state.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 403 Forbidden
|
||||
*/
|
||||
export class ForbiddenException extends ExceptionWithHttpState {
|
||||
status = 403;
|
||||
|
||||
constructor(message = 'Forbidden') {
|
||||
super(403, message);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import { HttpException } from './httpException.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 403 Forbidden
|
||||
*/
|
||||
export class ForbiddenException extends HttpException {
|
||||
constructor(message = 'Forbidden') {
|
||||
super(403, message);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
export class HttpException extends Error {
|
||||
constructor(
|
||||
public status: number,
|
||||
message: string
|
||||
) {
|
||||
super(message);
|
||||
}
|
||||
}
|
12
backend/src/exceptions/not-found-exception.ts
Normal file
12
backend/src/exceptions/not-found-exception.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { ExceptionWithHttpState } from './exception-with-http-state.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 404 Not Found
|
||||
*/
|
||||
export class NotFoundException extends ExceptionWithHttpState {
|
||||
public status = 404;
|
||||
|
||||
constructor(error: string) {
|
||||
super(404, error);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import { HttpException } from './httpException.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 404 Not Found
|
||||
*/
|
||||
export class NotFoundException extends HttpException {
|
||||
constructor(message = 'Not Found') {
|
||||
super(404, message);
|
||||
}
|
||||
}
|
10
backend/src/exceptions/unauthorized-exception.ts
Normal file
10
backend/src/exceptions/unauthorized-exception.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { ExceptionWithHttpState } from './exception-with-http-state.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 401 Unauthorized
|
||||
*/
|
||||
export class UnauthorizedException extends ExceptionWithHttpState {
|
||||
constructor(message = 'Unauthorized') {
|
||||
super(401, message);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
import { HttpException } from './httpException.js';
|
||||
|
||||
/**
|
||||
* Exception for HTTP 401 Unauthorized
|
||||
*/
|
||||
export class UnauthorizedException extends HttpException {
|
||||
constructor(message = 'Unauthorized') {
|
||||
super(401, message);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue