feat(backend): Eigen error handler toegevoegd.

Hiervoor was ook refactoring aan de exception-klassen nodig.
This commit is contained in:
Gerald Schmittinger 2025-03-30 12:25:41 +02:00
parent bc94b25a6a
commit aaa71aa648
14 changed files with 103 additions and 55 deletions

View file

@ -0,0 +1,10 @@
import {ExceptionWithHttpState} from "./exception-with-http-state.js";
/**
* Exception for HTTP 400 Bad Request
*/
export abstract class BadRequestException extends ExceptionWithHttpState {
constructor(error: string) {
super(400, error);
}
}

View 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);
}
}

View file

@ -0,0 +1,9 @@
/**
* Exceptions which are associated with a HTTP error code.
*/
export abstract class ExceptionWithHttpState extends Error {
constructor(public status: number, public error: string) {
super(error);
}
}

View 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: string = 'Forbidden') {
super(403, message);
}
}

View 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);
}
}

View 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: string = 'Unauthorized') {
super(401, message);
}
}