From 12420357442b75be31b39ac15c221a515ed98e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Mon, 10 May 2021 09:11:29 +0200 Subject: [PATCH] Catch all errors thrown by a Speed Provider's getCostForStep function --- CHANGELOG.md | 5 +++++ src/api.js | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f857013..ea5c0f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/api.js b/src/api.js index 198f16c..3c417ed 100644 --- a/src/api.js +++ b/src/api.js @@ -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) {