Skip to content

Commit d6297fb

Browse files
committed
fix(router): avoiding throw for app stability improvements
1 parent 2954860 commit d6297fb

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Diff for: nativescript-angular/router/ns-location-strategy.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,21 @@ export class NSLocationStrategy extends LocationStrategy {
274274

275275
// Methods for syncing with page navigation in PageRouterOutlet
276276
public _beginBackPageNavigation(name: string) {
277-
routerLog("NSLocationStrategy.startGoBack()");
278277
if (this._isPageNavigationBack) {
279-
throw new Error("Calling startGoBack while going back.");
278+
routerLog("Warn: Attempted to call startGoBack while going back. Ignoring.");
279+
return;
280280
}
281+
routerLog("NSLocationStrategy.startGoBack()");
281282
this._isPageNavigationBack = true;
282283
this.currentOutlet = name;
283284
}
284285

285286
public _finishBackPageNavigation() {
286-
routerLog("NSLocationStrategy.finishBackPageNavigation()");
287287
if (!this._isPageNavigationBack) {
288-
throw new Error("Calling endGoBack while not going back.");
288+
routerLog("Warn: Attempted to call endGoBack while not going back. Ignoring.");
289+
return;
289290
}
291+
routerLog("NSLocationStrategy.finishBackPageNavigation()");
290292
this._isPageNavigationBack = false;
291293
}
292294

@@ -306,18 +308,20 @@ export class NSLocationStrategy extends LocationStrategy {
306308
}
307309

308310
public _beginCloseModalNavigation(): void {
309-
routerLog("NSLocationStrategy.startCloseModal()");
310311
if (this._isModalClosing) {
311-
throw new Error("Calling startCloseModal while closing modal.");
312+
routerLog("Warn: Attempted to call startCloseModal while closing modal. Ignoring.");
313+
return;
312314
}
315+
routerLog("NSLocationStrategy.startCloseModal()");
313316
this._isModalClosing = true;
314317
}
315318

316319
public _finishCloseModalNavigation() {
317-
routerLog("NSLocationStrategy.finishCloseModalNavigation()");
318320
if (!this._isModalClosing) {
319-
throw new Error("Calling startCloseModal while not closing modal.");
321+
routerLog("Warn: Attempted to call startCloseModal while not closing modal. Ignoring.");
322+
return;
320323
}
324+
routerLog("NSLocationStrategy.finishCloseModalNavigation()");
321325
this._isModalClosing = false;
322326
}
323327

0 commit comments

Comments
 (0)