mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-08-20 06:35:52 +02:00
* 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
53 lines
997 B
TypeScript
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";
|
|
}
|
|
}
|