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

View file

@ -193,7 +193,10 @@ class DeviceReadingDisplay {
}))); })));
} catch(error) { } catch(error) {
// TODO: Display a nice error message here instead of an alert() // 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); console.error(error);
return null; return null;
} }