@nestia/core
Version:
Super-fast validation decorators of NestJS
39 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.route_error = route_error;
const common_1 = require("@nestjs/common");
const rxjs_1 = require("rxjs");
const ExceptionManager_1 = require("../../utils/ExceptionManager");
/** @internal */
function route_error(request, error) {
var _a, _b, _c;
error = (() => {
// HTTP-ERROR
if (error instanceof common_1.HttpException)
return error;
// CUSTOM-REGISTERED ERROR
for (const [creator, closure] of ExceptionManager_1.ExceptionManager.tuples)
if (error instanceof creator)
return closure(error);
// MAYBE INTERNAL ERROR
return error;
})();
try {
error.method = request.method;
error.path =
(_c = (_a = request.path) !== null && _a !== void 0 ? _a : (_b = request.routeOptions) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : request.routerPath;
}
catch (_d) { }
setTimeout(() => {
for (const listener of ExceptionManager_1.ExceptionManager.listeners) {
try {
const res = listener(error);
if (typeof res === "object" && typeof res.catch === "function")
res.catch(() => { });
}
catch (_a) { }
}
}, 0);
return (0, rxjs_1.throwError)(() => error);
}
//# sourceMappingURL=route_error.js.map