Custom error in case Not Found
budarin opened this issue · comments
node.js version: 11.0.0
npm/yarn and version: 6.4.1
koa-router
version: 7.4.0
koa
version: 2.6.2
Code sample:
Expected Behavior:
Actual Behavior:
Additional steps, HTTP request details, or to reproduce the behavior or a test case:
I want to have custom error mesage in case when route is not found in router.
How could I achieve this?
Thanks
const Router = require('koa-router');
const router = new Router();
router.get('/exist',middleware);
// Need put last.
router.all('*', (ctx) => {
ctx.body = 'Not found Custom';
ctx.status = 404;
return ctx;
});
thanks