UNPKG

@am92/kms

Version:
64 lines (63 loc) 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KmsError = void 0; const CONFIG_1 = require("./CONFIG"); /** @ignore */ const DEFAULT_ERROR_MSG = 'Kms Error'; /** @ignore */ const DEFAULT_ERROR_STATUS_CODE = 500; /** @ignore */ const DEFAULT_ERROR_CODE = 'KmsError::GENERIC'; /** * Error class whose instance is thrown in case of any error. * * @class * @typedef {KmsError} * @extends {Error} */ class KmsError extends Error { /** * Flag to identify if error is a custom error. */ _isCustomError = true; /** * Flag to identify if error is a KmsError. */ _isKmsError = true; /** * Node project from which Error is thrown. */ service; /** * Error's message string. */ message; /** * HTTP status code associated with the error. */ statusCode; /** * Error Code. */ errorCode; /** * Error object. */ error; /** * Creates an instance of KmsError. * * @constructor * @param [e] Any Error instance to wrap with KmsError. * @param [eMap] KmsErrorMap to rewrap error for better understanding. */ constructor(e, eMap) { super(); this.service = CONFIG_1.SERVICE; this.message = eMap?.message || e?.message || DEFAULT_ERROR_MSG; this.statusCode = eMap?.statusCode || DEFAULT_ERROR_STATUS_CODE; this.errorCode = eMap?.errorCode || e?.code || DEFAULT_ERROR_CODE; this.error = e; } } exports.KmsError = KmsError;