SurfSense/surfsense_web/lib/error.ts

41 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-11-14 00:25:08 +02:00
export class AppError extends Error {
2025-11-15 02:07:20 +02:00
status?: number;
statusText?: string;
constructor(message: string, status?: number, statusText?: string) {
2025-11-14 00:42:19 +02:00
super(message);
2025-11-15 02:07:20 +02:00
this.name = this.constructor.name; // User friendly
this.status = status;
this.statusText = statusText; // Dev friendly
2025-11-14 00:42:19 +02:00
}
2025-11-14 00:25:08 +02:00
}
export class NetworkError extends AppError {
2025-11-15 02:07:20 +02:00
constructor(message: string, status?: number, statusText?: string) {
super(message, status, statusText);
2025-11-14 00:42:19 +02:00
}
2025-11-14 00:25:08 +02:00
}
export class ValidationError extends AppError {
2025-11-15 02:07:20 +02:00
constructor(message: string, status?: number, statusText?: string) {
super(message, status, statusText);
2025-11-14 00:42:19 +02:00
}
2025-11-14 00:25:08 +02:00
}
export class AuthenticationError extends AppError {
2025-11-15 02:07:20 +02:00
constructor(message: string, status?: number, statusText?: string) {
super(message, status, statusText);
2025-11-14 00:42:19 +02:00
}
2025-11-14 00:25:08 +02:00
}
export class AuthorizationError extends AppError {
2025-11-15 02:07:20 +02:00
constructor(message: string, status?: number, statusText?: string) {
super(message, status, statusText);
}
}
export class NotFoundError extends AppError {
constructor(message: string, status?: number, statusText?: string) {
super(message, status, statusText);
2025-11-14 00:42:19 +02:00
}
2025-11-14 00:25:08 +02:00
}