filesafe/controllers/utils/ServerError.js
Bobby b35f4ae6eb
fix: remove token from local storage if invalid
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
2022-05-06 21:58:23 +07:00

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