1
0
Fork 0
mirror of synced 2024-09-29 08:41:16 +13:00

adding new custom feature disabled error

This commit is contained in:
Peter Clement 2022-07-25 19:45:50 +01:00
parent 9bb32f610c
commit d1657fe976
4 changed files with 17 additions and 0 deletions

View file

@ -37,6 +37,7 @@ module.exports = {
types,
errors: {
UsageLimitError: licensing.UsageLimitError,
FeatureDisabledError: licensing.FeatureDisabledError,
HTTPError: http.HTTPError,
},
getPublicError,

View file

@ -4,6 +4,7 @@ const type = "license_error"
const codes = {
USAGE_LIMIT_EXCEEDED: "usage_limit_exceeded",
FEATURE_DISABLED: "feature_disabled",
}
const context = {
@ -12,6 +13,11 @@ const context = {
limitName: err.limitName,
}
},
[codes.FEATURE_DISABLED]: err => {
return {
limitName: err.limitName,
}
},
}
class UsageLimitError extends HTTPError {
@ -21,9 +27,17 @@ class UsageLimitError extends HTTPError {
}
}
class FeatureDisabledError extends HTTPError {
constructor(message, limitName) {
super(message, 400, codes.FEATURE_DISABLED, type)
this.limitName = limitName
}
}
module.exports = {
type,
codes,
context,
UsageLimitError,
FeatureDisabledError,
}

View file

@ -3,6 +3,7 @@ const errorClasses = errors.errors
import * as events from "./events"
import * as migrations from "./migrations"
import * as users from "./users"
import * as roles from "./security/roles"
import * as accounts from "./cloud/accounts"
import * as installation from "./installation"
import env from "./environment"
@ -51,6 +52,7 @@ const core = {
installation,
errors,
logging,
roles,
...errorClasses,
}

View file