UNPKG

@adonisjs/generic-exceptions

Version:

List of generic exceptions to be used in all other repos

30 lines (29 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const NE = require("node-exceptions"); class RuntimeException extends NE.RuntimeException { static get errorsDoc() { return 'http://adonisjs.com/errors'; } static missingConfig(key, configLocation) { const message = `${key} is not defined inside ${configLocation} file`; return new this(message, 500, 'E_MISSING_CONFIG', this.errorsDoc); } static missingAppKey(provider) { const message = `Make sure to define appKey inside config/app.js file before using ${provider} provider`; return new this(message, 500, 'E_MISSING_APP_KEY', this.errorsDoc); } static missingEnvKey(key) { const message = `Make sure to define environment variable ${key}.`; return new this(message, 500, 'E_MISSING_ENV_KEY', this.errorsDoc); } static incompleteConfig(missingKeys, file, forKey) { const baseMessage = `Make sure to define ${missingKeys.join(', ')}`; const message = forKey ? `${baseMessage} on ${forKey} inside ${file}` : `${baseMessage} inside ${file}`; return new this(message, 500, 'E_INCOMPLETE_CONFIG', this.errorsDoc); } static invoke(message, status = 500, code = 'E_RUNTIME_ERROR') { return new this(message, status, code, this.errorsDoc); } } exports.RuntimeException = RuntimeException;