import http from 'http' export default class StatusError extends Error { status: number constructor(status = 500, message = http.STATUS_CODES[status] || 'Unknown Error', options?: Record) { 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, } } }