INNER CODE UNIT · JavaScript
Error
csfloat/inspect · errors.js:1
class Error {
constructor(message, internalCode, statusCode) {
this.message = message;
this.code = internalCode;
this.statusCode = statusCode; // HTTP Status Code
}
getJSON() {
return {error: this.message, code: this.code, status: this.statusCode};
}
respond(res) {
res.status(this.statusCode).json(this.getJSON());
}
toString() {
return `[Code ${this.code}] - ${this.message}`;
}