From bd047f31f855e41a3a643adddb33e44c44bb615d Mon Sep 17 00:00:00 2001 From: Logan B <3870583+thinkpoop@users.noreply.github.com> Date: Thu, 12 Jun 2025 18:39:18 -0500 Subject: [PATCH] [owmweather] simplify error handling --- apps/owmweather/lib.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/owmweather/lib.js b/apps/owmweather/lib.js index b4893d484..2f6af5f7b 100644 --- a/apps/owmweather/lib.js +++ b/apps/owmweather/lib.js @@ -27,9 +27,8 @@ function parseWeather(response) { json.weather = weather; require("Storage").writeJSON('weather.json', json); if (require("Storage").read("weather")!==undefined) require("weather").emit("update", json.weather); - return undefined; } else { - return /*LANG*/"Not OWM data"; + throw /*LANG*/"Not OWM data"; } } @@ -43,12 +42,8 @@ exports.pull = function(completionCallback, errorCallback) { 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; if (Bangle.http){ Bangle.http(uri, {timeout:10000}).then(event => { - let result = parseWeather(event.resp); - if (result === undefined) { - if (completionCallback) completionCallback(); - } else { - if (errorCallback) errorCallback(result); - } + parseWeather(event.resp); + if (completionCallback) completionCallback(); }).catch((e)=>{ if (errorCallback) errorCallback(e); });