WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 339 forks source link

JSON error messages for REST & WebSockets API #666

Open dhylands opened 6 years ago

dhylands commented 6 years ago

If I connected to a gateway which previously had a zigbee light enabled, but I restart the Pi without the Zigbee dongle, then I see the following errors in the web console (of the browser)

Error fetching on/off switch status SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

Which tells me that the things controller is returning a non-JSON response for error cases.

benfrancis commented 6 years ago

Many of our error messages aren't in JSON format, they're just strings. We could probably do a better job of error handling :)

dhylands commented 6 years ago

Which is why I created this issue (to do a better job of error handling)

mrstegeman commented 6 years ago

Requires mozilla-iot/wot#65

benfrancis commented 6 years ago

Let's use this to track adding proper machine-readable error codes to the REST & WebSocket APIs, and target it for 0.6 as part of our "Thing UI Robustness" theme.