feat: browser router add custom error
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { QueryRouterServer } from '@kevisual/router';
|
||||
import { CustomError, QueryRouterServer } from '@kevisual/router/browser';
|
||||
|
||||
const router = new QueryRouterServer();
|
||||
|
||||
@@ -12,6 +12,18 @@ router
|
||||
})
|
||||
.addTo(router);
|
||||
|
||||
router
|
||||
.route({
|
||||
path: 'hello',
|
||||
key: 'world2',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = 'Hello, world!';
|
||||
// throw new CustomError('error');
|
||||
throw new CustomError(5000, 'error');
|
||||
})
|
||||
.addTo(router);
|
||||
|
||||
router
|
||||
.run({
|
||||
path: 'hello',
|
||||
@@ -20,3 +32,12 @@ router
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
|
||||
router
|
||||
.run({
|
||||
path: 'hello',
|
||||
key: 'world2',
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
|
Reference in New Issue
Block a user