diff --git a/radio.js b/radio.js index 1fd7976..01beb5f 100644 --- a/radio.js +++ b/radio.js @@ -10,22 +10,23 @@ const config = require("./config"); const util = require("./util"); async function getRadioStatus() { - let status = await fetch('http://radio.home/status-json.xsl').then(r => r.json()) - .catch(() => { - return { - server_start_iso8601: "n/a", - server_start_date: "n/a", - song: "n/a", - listener_peak: "n/a", - listeners: "n/a" - } - }); - return { - server_start_iso8601: status.icestats.server_start_iso8601, - server_start_date: util.datetime(status.icestats.server_start_iso8601, util.post_date_format), - song: `${status.icestats.source.artist} - ${status.icestats.source.title}`, - listener_peak: status.icestats.source.listener_peak, - listeners: status.icestats.source.listeners + try { + let status = await fetch('http://radio.home/status-json.xsl').then(r => r.json()); + return { + server_start_iso8601: status.icestats.server_start_iso8601, + server_start_date: util.datetime(status.icestats.server_start_iso8601, util.post_date_format), + song: `${status.icestats.source.artist} - ${status.icestats.source.title}`, + listener_peak: status.icestats.source.listener_peak, + listeners: status.icestats.source.listeners + } + } catch { + return { + server_start_iso8601: "n/a", + server_start_date: "n/a", + song: "n/a", + listener_peak: "n/a", + listeners: "n/a" + } } }