Skip to content

Commit bb59ee7

Browse files
committed
Fixed crash in weatherunderground on malformed/missing server response
1 parent 43d17f8 commit bb59ee7

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,7 @@
138138
* Added new weather underground api (post January 2019)
139139

140140
## 2.8.1
141-
* Fixed crash in openweathermap api that occured since v2.8.0
141+
* Fixed crash in openweathermap api that occured since v2.8.0
142+
143+
## 2.8.2
144+
* Fixed crash in weatherunderground on malformed/missing server response

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
This is a weather plugin for [homebridge](https://github.com/nfarina/homebridge) that features current observations, daily forecasts and history graphs for multiple locations and services. You can download it via [npm](https://www.npmjs.com/package/homebridge-weather-plus).
88

9-
If you like this plugin, I would be very grateful for any support to stay awake while coding:
10-
<a href="https://www.buymeacoffee.com/2D1nUuK36" target="_blank"><img src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto !important;" ></a>
9+
If you like this plugin, I would be very grateful for your support:
10+
11+
<a href="https://www.buymeacoffee.com/2D1nUuK36" target="_blank"><img width="140" src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee"></a>
1112

1213
Feel free to leave any feedback [here](https://github.com/naofireblade/homebridge-weather-plus/issues).
1314

api/weatherunderground.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ class WundergroundAPI {
4242
request(encodeURI(queryUri), function (err, response, body) {
4343
if (!err) {
4444
// Current weather report
45-
const jsonObj = JSON.parse(body);
46-
debug(JSON.stringify(jsonObj, null, 2));
47-
48-
weather.report = that.parseReport(jsonObj);
49-
callback(null, weather);
45+
try
46+
{
47+
const jsonObj = JSON.parse(body);
48+
debug(JSON.stringify(jsonObj, null, 2));
49+
50+
weather.report = that.parseReport(jsonObj);
51+
callback(null, weather);
52+
} catch (e) {
53+
debug("Error retrieving weather report and forecast");
54+
debug("Error Message: " + e);
55+
callback(e);
56+
}
5057
} else {
5158
debug("Error retrieving weather report and forecast");
5259
debug("Error Message: " + err);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "homebridge-weather-plus",
3-
"version": "2.8.1",
3+
"version": "2.8.2",
44
"description": "A comprehensive weather plugin for homekit with current observations, forecasts and history.",
55
"license": "MIT",
66
"keywords": [

0 commit comments

Comments
 (0)