From 644351033614cfc724265d0025eb6fd1f113a136 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 May 2019 15:02:06 +0200 Subject: [PATCH] refactor: fetchRoute & notFoundException Don't throw exception when route does not exist. Also verify the not found callback isn't null before applying it. --- src/leafeon.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/leafeon.ts b/src/leafeon.ts index 9f393b2..4320472 100644 --- a/src/leafeon.ts +++ b/src/leafeon.ts @@ -128,7 +128,9 @@ export class Router extends RouterRequest { * @function notFoundException */ public notFoundException = (): void => { - this.notFoundCallback.apply(null, []); + if (this.notFoundCallback !== null) { + this.notFoundCallback.apply(null, []); + } } /** @@ -205,7 +207,7 @@ export class Router extends RouterRequest { }); if (targetRoute === undefined) { - return this.exception('Route ' + route + ' does not exist.'); + return this.notFoundException(); } if (!targetRoute.paramsEnabled) {