mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
b35f4ae6eb
this required expanding our custom error classes with support for arbitrary internal api error codes however it'll only be used for invalid token errors for now (10001) no plan to assign codes to other existing api errors at that point it's probably better to redo the whole api infrastructure
22 lines
343 B
JavaScript
22 lines
343 B
JavaScript
class ServerError extends Error {
|
|
constructor (message, options = {}) {
|
|
super(message)
|
|
|
|
const {
|
|
statusCode,
|
|
code,
|
|
logStack
|
|
} = options
|
|
|
|
this.statusCode = statusCode !== undefined
|
|
? statusCode
|
|
: 500
|
|
|
|
this.code = code
|
|
|
|
this.logStack = logStack || false
|
|
}
|
|
}
|
|
|
|
module.exports = ServerError
|