UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

25 lines 1.01 kB
import { UnleashError } from './unleash-error.js'; class PermissionError extends UnleashError { constructor(permission = [], environment) { const permissions = Array.isArray(permission) ? permission : [permission]; const permissionsMessage = permissions.length === 1 ? `the "${permissions[0]}" permission` : `one of the following permissions: ${permissions .map((perm) => `"${perm}"`) .join(', ')}`; const message = `You don't have the required permissions to perform this operation. To perform this action, you need ${permissionsMessage}${environment ? ` in the "${environment}" environment.` : `.`}`; super(message); this.statusCode = 403; this.permissions = permissions; } toJSON() { return { ...super.toJSON(), permissions: this.permissions, }; } } export default PermissionError; //# sourceMappingURL=permission-error.js.map