updated universal-router to 7.0.0

This commit is contained in:
Andrea Jemmett
2018-12-12 10:33:46 +01:00
parent cca60bd544
commit 40a1445181
2 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -1,8 +1,9 @@
// Type definitions for universal-router 6.0
// Type definitions for universal-router 7.0
// Project: https://github.com/kriasoft/universal-router
// Definitions by: Jack Moore <https://github.com/jtmthf>
// Tomek Łaziuk <https://github.com/tlaziuk>
// Lodin <https://github.com/Lodin>
// acidghost <https://github.com/acidghost>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -101,7 +102,7 @@ export interface Options<C extends Context = Context, R = any> {
context?: C;
baseUrl?: string;
resolveRoute?: (context: ActionContext<C, R> & C, params: Params) => any;
errorHandler?: (error: Error & { context: C, code: number }) => any;
errorHandler?: (error: Error & { status: number }, context: C) => any;
}
/**
@@ -12,10 +12,10 @@ new UniversalRouter(
user: 'name',
},
baseUrl: '/base',
errorHandler: (error) => {
errorHandler: (error, context) => {
console.error(error);
console.dir(error.context);
return error.code === 404
console.dir(context);
return error.status === 404
? '<h1>Page Not Found</h1>'
: '<h1>Oops! Something went wrong</h1>';
},