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, types,
errors: { errors: {
UsageLimitError: licensing.UsageLimitError, UsageLimitError: licensing.UsageLimitError,
FeatureDisabledError: licensing.FeatureDisabledError,
HTTPError: http.HTTPError, HTTPError: http.HTTPError,
}, },
getPublicError, getPublicError,

View File

@ -4,6 +4,7 @@ const type = "license_error"
const codes = { const codes = {
USAGE_LIMIT_EXCEEDED: "usage_limit_exceeded", USAGE_LIMIT_EXCEEDED: "usage_limit_exceeded",
FEATURE_DISABLED: "feature_disabled",
} }
const context = { const context = {
@ -12,6 +13,11 @@ const context = {
limitName: err.limitName, limitName: err.limitName,
} }
}, },
[codes.FEATURE_DISABLED]: err => {
return {
limitName: err.limitName,
}
},
} }
class UsageLimitError extends HTTPError { 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 = { module.exports = {
type, type,
codes, codes,
context, context,
UsageLimitError, UsageLimitError,
FeatureDisabledError,
} }

View File

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

View File