Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
refactor: fetchRoute & notFoundException
Browse files Browse the repository at this point in the history
Don't throw exception when route does not exist. Also verify the not found callback isn't null before applying it.
  • Loading branch information
sundowndev authored May 15, 2019
1 parent ff5657d commit 6443510
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/leafeon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, []);
}
}

/**
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6443510

Please sign in to comment.