Skip to content

Commit

Permalink
feat(router): restore previous location after exceeding max nav attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanrsmith committed Jun 23, 2015
1 parent 5f378c1 commit 2e03ca0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ export class AppRouter extends Router {

if (!instructionCount) {
this.events.publish('router:navigation:processing', { instruction });
} else if (instructionCount === this.maxInstructionCount - 1) {
logger.error(`${instructionCount + 1} navigation instructions have been attempted without success. Restoring last known good location.`);
restorePreviousLocation(this);
return this.dequeueInstruction(instructionCount + 1);
} else if (instructionCount > this.maxInstructionCount) {
throw new Error(`Maximum navigation attempts exceeded. ${this.maxInstructionCount} navigation instructions have been attempted without success. Giving up.`);
throw new Error(`Maximum navigation attempts exceeded. Giving up.`);
}

let context = this.createNavigationContext(instruction);
Expand Down

0 comments on commit 2e03ca0

Please sign in to comment.