UNPKG

736 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.errorHandler = void 0;
4const errors_1 = require("@feathersjs/errors");
5const errorHandler = () => async (ctx, next) => {
6 try {
7 await next();
8 if (ctx.body === undefined) {
9 throw new errors_1.NotFound(`Path ${ctx.path} not found`);
10 }
11 }
12 catch (error) {
13 ctx.response.status = error instanceof errors_1.FeathersError ? error.code : 500;
14 ctx.body =
15 typeof error.toJSON === 'function'
16 ? error.toJSON()
17 : {
18 message: error.message
19 };
20 }
21};
22exports.errorHandler = errorHandler;
23//# sourceMappingURL=handlers.js.map
\No newline at end of file