From e6d058a911cd95bb67bc84fa1d0efe9670e2e14c Mon Sep 17 00:00:00 2001 From: Prageeth Silva Date: Sun, 18 Jul 2021 20:18:40 +0200 Subject: [PATCH] WTH exception handling (#1) * fix the `wth` exception * add comment for the wth error * fix indentation --- src/router.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/router.js b/src/router.js index a037f69..1dafebb 100644 --- a/src/router.js +++ b/src/router.js @@ -172,6 +172,7 @@ export const getWorkingPath = (parentRouterId) => { } const stackEntry = stack[parentRouterId]; if (!stackEntry) { + // this should not be reached at all throw 'wth'; } @@ -239,6 +240,10 @@ const process = (stackObj, directCall) => { reducedPath: previousReducedPath } = stackObj; + if (!stack[routerId]) { + return; + } + const currentPath = getWorkingPath(parentRouterId); let route = null; let targetFunction = null; @@ -270,10 +275,6 @@ const process = (stackObj, directCall) => { break; } - if (!stack[routerId]) { - return; - } - if (!anyMatched) { route = null; targetFunction = null;