Skip to content

Commit

Permalink
Catch all errors thrown by a Speed Provider's getCostForStep function
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelVo committed May 10, 2021
1 parent 49542a6 commit 1242035
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## In development
### Bugfixes
- Fixed a bug where a bug in a Speed Provider could lead to the ruler getting stuck, leaving the token immovable


## 1.6.3
### Bugfixes
- If the movement history for a token is being updated (for example by a history reset by the gm) while a player is currently measuring a distance for that token the history change is now being reflected in the active measurement.
Expand Down
12 changes: 9 additions & 3 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,16 @@ export function getUnreachableColorFromSpeedProvider() {
}

export function getCostFromSpeedProvider(token, area) {
if (currentSpeedProvider instanceof Function) {
return SpeedProvider.prototype.getCostForStep.call(undefined, token, area);
try {
if (currentSpeedProvider instanceof Function) {
return SpeedProvider.prototype.getCostForStep.call(undefined, token, area);
}
return currentSpeedProvider.getCostForStep(token, area);
}
catch (e) {
console.error(e);
return 1;
}
return currentSpeedProvider.getCostForStep(token, area);
}

export function getMovedDistanceFromToken(token) {
Expand Down

0 comments on commit 1242035

Please sign in to comment.