Skip to content

Commit bd047f3

Browse files
committed
[owmweather] simplify error handling
1 parent 34a4d35 commit bd047f3

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

apps/owmweather/lib.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ function parseWeather(response) {
2727
json.weather = weather;
2828
require("Storage").writeJSON('weather.json', json);
2929
if (require("Storage").read("weather")!==undefined) require("weather").emit("update", json.weather);
30-
return undefined;
3130
} else {
32-
return /*LANG*/"Not OWM data";
31+
throw /*LANG*/"Not OWM data";
3332
}
3433
}
3534

@@ -43,12 +42,8 @@ exports.pull = function(completionCallback, errorCallback) {
4342
let uri = "https://api.openweathermap.org/data/2.5/weather?lat=" + location.lat.toFixed(2) + "&lon=" + location.lon.toFixed(2) + "&exclude=hourly,daily&appid=" + settings.apikey;
4443
if (Bangle.http){
4544
Bangle.http(uri, {timeout:10000}).then(event => {
46-
let result = parseWeather(event.resp);
47-
if (result === undefined) {
48-
if (completionCallback) completionCallback();
49-
} else {
50-
if (errorCallback) errorCallback(result);
51-
}
45+
parseWeather(event.resp);
46+
if (completionCallback) completionCallback();
5247
}).catch((e)=>{
5348
if (errorCallback) errorCallback(e);
5449
});

0 commit comments

Comments
 (0)