- Added api-security-hardening (helmet, rate limits) - Added nodejs-backend-patterns (error handling) - Added observability-monitoring (pino logging) - Added websocket-engineer (socket.io real-time updates) - Added docker (Multi-stage build, compose) - Added vitest (testing configuration and store tests) - Added data-visualizer (MetricsBar and HostChart) - Added infrastructure-monitoring/proxmox-admin/network-engineer types - Fixed UI accessibility and styling - Cleaned up node_modules tracking
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
/**
|
|
* Custom Error Classes for Homelab Topology API
|
|
*
|
|
* Structured error hierarchy following nodejs-backend-patterns skill.
|
|
* All operational errors extend AppError with appropriate HTTP status codes.
|
|
*/
|
|
|
|
export class AppError extends Error {
|
|
constructor(
|
|
public message: string,
|
|
public statusCode: number = 500,
|
|
public isOperational: boolean = true
|
|
) {
|
|
super(message);
|
|
Object.setPrototypeOf(this, AppError.prototype);
|
|
Error.captureStackTrace(this, this.constructor);
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends AppError {
|
|
constructor(message: string = 'Resource not found') {
|
|
super(message, 404);
|
|
}
|
|
}
|
|
|
|
export class ValidationError extends AppError {
|
|
constructor(message: string, public errors?: Array<{ field: string; message: string }>) {
|
|
super(message, 400);
|
|
}
|
|
}
|
|
|
|
export class ServiceUnavailableError extends AppError {
|
|
constructor(message: string = 'Service temporarily unavailable') {
|
|
super(message, 503);
|
|
}
|
|
}
|