We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 503a668 commit 123e8ffCopy full SHA for 123e8ff
src/app.js
@@ -55,13 +55,29 @@ app.use(launches.routes());
55
app.use(upcoming.routes());
56
app.use(parts.routes());
57
58
-// Error Handler
+// 500 Error Handler
59
app.use(async (ctx, next) => {
60
try {
61
await next();
62
} catch (err) {
63
ctx.status = err.status || 500;
64
- ctx.body = err.message;
+ ctx.body = {
65
+ error: 'No results found',
66
+ };
67
+ ctx.app.emit('error', err, ctx);
68
+ }
69
+});
70
+
71
+// 404 Error Handler
72
+app.use(async (ctx, next) => {
73
+ try {
74
+ await next();
75
+ if (ctx.status === 404) ctx.throw(404);
76
+ } catch (err) {
77
+ ctx.throw(err);
78
79
+ error: 'Internal Server Error',
80
81
ctx.app.emit('error', err, ctx);
82
}
83
});
0 commit comments