1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.errorHandler = void 0;
|
4 | const errors_1 = require("@feathersjs/errors");
|
5 | const 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 | };
|
22 | exports.errorHandler = errorHandler;
|
23 |
|
\ | No newline at end of file |