mirror of
https://github.com/ConnectedHumber/Air-Quality-Web
synced 2024-11-24 06:43:01 +00:00
Bugfix: Wrap string-based errors in an instance of error with a helpful default message.
This commit is contained in:
parent
1baa755f0f
commit
b417cce31d
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue