1
0
Fork 0
mirror of synced 2024-06-27 02:20:35 +12:00
budibase/packages/backend-core/src/errors/index.js

44 lines
721 B
JavaScript
Raw Normal View History

2022-04-08 12:28:22 +12:00
const http = require("./http")
const licensing = require("./licensing")
const codes = {
...licensing.codes,
}
2022-04-08 12:28:22 +12:00
const types = [licensing.type]
const context = {
...licensing.context,
}
const getPublicError = err => {
let error
if (err.code || err.type) {
// add generic error information
error = {
code: err.code,
type: err.type,
}
if (err.code && context[err.code]) {
error = {
...error,
// get any additional context from this error
...context[err.code](err),
}
}
}
return error
}
module.exports = {
codes,
types,
2022-04-08 12:28:22 +12:00
errors: {
UsageLimitError: licensing.UsageLimitError,
HTTPError: http.HTTPError,
},
getPublicError,
}