UNPKG

@am92/kms

Version:
68 lines (67 loc) 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeKmsError = void 0; const CONFIG_1 = require("../../CONFIG"); /** @ignore */ const DEFAULT_ERROR_MSG = 'Node Kms Error'; /** @ignore */ const DEFAULT_ERROR_STATUS_CODE = 500; /** @ignore */ const DEFAULT_ERROR_CODE = 'NodeKmsError::GENERIC'; /** * Error class whose instance is thrown in case of any error. * * @class * @typedef {NodeKmsError} * @extends {Error} */ class NodeKmsError extends Error { /** * Flag to identify if error is a custom error. */ _isCustomError = true; /** * Flag to identify if error is a KmsError. */ _isKmsError = true; /** * Flag to identify if error is a NodeKmsError. */ _isNodeKmsError = 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 NodeKmsError. * * @constructor * @param [e] Any Error instance to wrap with NodeKmsError. * @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.NodeKmsError = NodeKmsError;