UNPKG

http-problem-details-mapper

Version:
26 lines 918 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DefaultErrorMapper = void 0; const IErrorMapper_1 = require("./IErrorMapper"); const StatusCodeErrorMapper_1 = require("./StatusCodeErrorMapper"); class DefaultErrorMapper extends IErrorMapper_1.ErrorMapper { constructor() { super(Error); } mapError(error) { let status = DefaultErrorMapper.__tryGetStatus(error.status) || DefaultErrorMapper.__tryGetStatus(error.code) || 500; return StatusCodeErrorMapper_1.StatusCodeErrorMapper.mapStatusCode(status); } static __tryGetStatus(status) { if (typeof status === 'number') { return status; } if (typeof status === 'string') { return Number.parseInt(status); } } } exports.DefaultErrorMapper = DefaultErrorMapper; //# sourceMappingURL=DefaultErrorMapper.js.map