brf/server/lib/status_error.ts
2025-11-23 21:44:01 +01:00

22 lines
448 B
TypeScript

import http from 'http'
export default class StatusError extends Error {
status: number
constructor(status = 500, message = http.STATUS_CODES[status] || 'Unknown Error', options?: Record<string, ANY>) {
super(message, options)
this.name = this.constructor.name
this.status = status
}
toJSON() {
return {
name: this.name,
message: this.message,
status: this.status,
stack: this.stack,
}
}
}