UNPKG

@am92/kms

Version:
70 lines (69 loc) 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AwsKmsError = void 0; const CONFIG_1 = require("../../CONFIG"); /** @ignore */ const DEFAULT_ERROR_MSG = 'Aws Kms Error'; /** @ignore */ const DEFAULT_ERROR_STATUS_CODE = 500; /** @ignore */ const DEFAULT_ERROR_CODE = 'AwsKmsError::GENERIC'; /** * Error class whose instance is thrown in case of any error. * * @class * @typedef {AwsKmsError} * @extends {Error} */ class AwsKmsError 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 AwsKmsError. */ _isAwsKmsError = true; /** * Aws 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 AwsKmsError. * * @constructor * @param [e] Any Error instance to wrap with AwsKmsError. * @param [eMap] KmsErrorMap to rewrap error for better understanding. */ constructor(e, eMap) { super(); const { $metadata: { httpStatusCode: eStatusCode = 500 } = {} } = e || {}; this.service = CONFIG_1.SERVICE; this.message = eMap?.message || e?.message || DEFAULT_ERROR_MSG; this.statusCode = eMap?.statusCode || eStatusCode || DEFAULT_ERROR_STATUS_CODE; this.errorCode = eMap?.errorCode || e?.code || DEFAULT_ERROR_CODE; this.error = e; } } exports.AwsKmsError = AwsKmsError;