From 914d2f15d937deafd92d70fb374d64db93342e6a Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Sun, 25 Dec 2022 19:17:52 +0100 Subject: [PATCH 1/2] Catch error when Bangle.getPressure() returns... ... undefined. This makes it so BW Clock doesn't hang when running in the emulator and is trying to display altitude. --- modules/clock_info.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/clock_info.js b/modules/clock_info.js index 643a9f6f7..95bad541c 100644 --- a/modules/clock_info.js +++ b/modules/clock_info.js @@ -71,11 +71,15 @@ exports.load = function() { bangleItems[2].emit("redraw"); } function altUpdateHandler() { - Bangle.getPressure().then(data=>{ - if (!data) return; - alt = Math.round(data.altitude) + "m"; - bangleItems[3].emit("redraw"); - }); + try { + Bangle.getPressure().then(data=>{ + if (!data) return; + alt = Math.round(data.altitude) + "m"; + bangleItems[3].emit("redraw"); + }); + } catch (error) { + print("Caught "+error+"\n in function altUpdateHandler in module clock_info"); + bangleItems[3].emit('redraw');} } // actual menu var menu = [{ From 5fd34247646041b513cefeb585a5412b83b71db4 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Tue, 27 Dec 2022 20:16:58 +0100 Subject: [PATCH 2/2] shorten the error variable --- modules/clock_info.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/clock_info.js b/modules/clock_info.js index 95bad541c..4d4aba622 100644 --- a/modules/clock_info.js +++ b/modules/clock_info.js @@ -77,8 +77,8 @@ exports.load = function() { alt = Math.round(data.altitude) + "m"; bangleItems[3].emit("redraw"); }); - } catch (error) { - print("Caught "+error+"\n in function altUpdateHandler in module clock_info"); + } catch (e) { + print("Caught "+e+"\n in function altUpdateHandler in module clock_info"); bangleItems[3].emit('redraw');} } // actual menu