UNPKG

644 BJavaScriptView Raw
1import path from 'path';
2
3spice.app.use(async(ctx, next) => {
4 try {
5 await next()
6 if(ctx.request.url.search('api') == -1){
7 const status = ctx.status || 404
8 if (status === 404) {
9 ctx.throw(404)
10 }
11 }
12 } catch (err) {
13 ctx.status = err.status || 500
14
15 await ctx.render('errors/index', {
16 error: err || 500
17 });
18 }
19})
20
21
22/*
23
24spice.app.on('error', function (err) {
25 if (process.env.NODE_ENV != 'test') {
26 //console.log('sent error %s to the cloud', err.message);
27 console.log("Global Error Handler:",err);
28 }
29});*/
\No newline at end of file