UNPKG

@breautek/storm

Version:

Object-Oriented REST API framework

69 lines (66 loc) 2.06 kB
"use strict"; /* Copyright 2017-2021 Norman Breau Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.StormError = void 0; const instance_1 = require("./instance"); const StatusCode_1 = require("./StatusCode"); const TAG = 'StormError'; class StormError extends Error { constructor(details) { super(); this.$details = details; let logger = (0, instance_1.getInstance)().getLogger(); logger.error(TAG, `${this.getMessage()}... See details below:`); logger.info(TAG, this.getPrivateDetails()); } /** * Sends details to the client. */ getPublicDetails() { return {}; } /** * Private details are only logged to the server log. * They are kept secret from the client. */ getPrivateDetails() { return this.$details; } getHTTPCode() { return StatusCode_1.StatusCode.INTERNAL_ERROR; } getErrorResponse() { return { name: this.constructor.name, message: this.getMessage(), code: this.getCode(), locale: { code: this.getLocaleCode(), parameters: this.getLocaleParameters() }, details: this.getPublicDetails() }; } getLocaleCode() { return null; } getLocaleParameters() { return null; } getExitCode() { return null; } } exports.StormError = StormError; //# sourceMappingURL=StormError.js.map