Files
appointment-booking-software/src/lib/server/utils/errors.ts
T
HendrikandGitHub 629351d6fa Scheduling api (#68)
* Additions for agent absencies and appointments. Schedule determination.

* Scheduling tests. Agent and appointment tests.

* Absence and Agent APIs

* Linting

* Appointment API (staffing side)

* LInting and fixed tests

* Centralised permission check

* Permission refactorings, session bugfixes

* Test fixes (first part)

* Test fixes

* Fixed type

* Linting fixes

* Fixed tests

* Formatting

* Data schema changes

* Adaptions to last merges and changes

* Incorporated changes as discussed in weekly

* Test fix
2025-09-15 16:22:41 +02:00

53 lines
997 B
TypeScript

import { json } from "@sveltejs/kit";
export class BackendError extends Error {
constructor(
message: string,
public code: number,
) {
super(message);
}
public toJson = () => json({ message: this.message }, { status: this.code });
}
export class AuthenticationError extends BackendError {
constructor(
message: string,
public code = 403,
) {
super(message, code);
this.name = "AuthenticationError";
}
}
export class ValidationError extends BackendError {
constructor(
message: string,
public code = 422,
) {
super(message, code);
this.name = "ValidationError";
}
}
export class NotFoundError extends BackendError {
constructor(
message: string,
public code = 404,
) {
super(message, code);
this.name = "ValidationError";
}
}
export class ConflictError extends BackendError {
constructor(
message: string,
public code = 409,
) {
super(message, code);
this.name = "ConflictError";
}
}