Bugfix: Wrap string-based errors in an instance of error with a helpful default message.

This commit is contained in:
Starbeamrainbowlabs 2019-02-20 17:35:13 +00:00
parent 1baa755f0f
commit b417cce31d
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 4 additions and 1 deletions

View File

@ -193,7 +193,10 @@ class DeviceReadingDisplay {
})));
} catch(error) {
// TODO: Display a nice error message here instead of an alert()
alert(error);
// Wrap it in an Error instance if needed
if(typeof error == "string")
error = new Error(error.length == 0 ? "An unknown error has ocurred. It's probably on the server." : error);
alert(error.message);
console.error(error);
return null;
}