WebService/errors/DefaultError.js
2026-01-27 22:43:59 +01:00

23 lines
596 B
JavaScript

class DefaultError extends Error {
constructor(code, message, cause, name) {
super(message)
this.code = code || 500
this.name = name || "DefaultError"
this.cause = cause || "Internal Server Error"
this.message = message || "Internal Server Error"
this.isOperational = true
Error.captureStackTrace(this, this.constructor)
}
serialize() {
return {
code: this.code,
name: this.name,
cause: this.cause,
message: this.message,
}
}
}
module.exports = DefaultError