diff --git a/src/widgets/autobrr/component.jsx b/src/widgets/autobrr/component.jsx index b78f48f61..d2769f0d4 100644 --- a/src/widgets/autobrr/component.jsx +++ b/src/widgets/autobrr/component.jsx @@ -13,8 +13,9 @@ export default function Component({ service }) { const { data: filtersData, error: filtersError } = useWidgetAPI(widget, "filters"); const { data: indexersData, error: indexersError } = useWidgetAPI(widget, "indexers"); - if (statsError || filtersError || indexersError) { - return ; + if (statsError || statsData?.error || filtersError || filtersData?.error || indexersError || indexersData?.error) { + const finalError = statsError ?? statsData?.error ?? filtersError ?? filtersData?.error ?? indexersError ?? indexersData?.error; + return ; } if (!statsData || !filtersData || !indexersData) { diff --git a/src/widgets/autobrr/widget.js b/src/widgets/autobrr/widget.js index 0254029ee..fb03f9d30 100644 --- a/src/widgets/autobrr/widget.js +++ b/src/widgets/autobrr/widget.js @@ -7,6 +7,10 @@ const widget = { mappings: { stats: { endpoint: "release/stats", + validate: [ + "push_approved_count", + "push_rejected_count" + ] }, filters: { endpoint: "filters", diff --git a/src/widgets/homebridge/component.jsx b/src/widgets/homebridge/component.jsx index 807cc49a8..3f1dc5dad 100644 --- a/src/widgets/homebridge/component.jsx +++ b/src/widgets/homebridge/component.jsx @@ -12,7 +12,8 @@ export default function Component({ service }) { const { data: homebridgeData, error: homebridgeError } = useWidgetAPI(widget, "info"); if (homebridgeError || homebridgeData?.error) { - return ; + const finalError = homebridgeError ?? homebridgeData.error; + return ; } if (!homebridgeData) { diff --git a/src/widgets/pyload/proxy.js b/src/widgets/pyload/proxy.js index 46b28684a..4a866d9cf 100644 --- a/src/widgets/pyload/proxy.js +++ b/src/widgets/pyload/proxy.js @@ -84,9 +84,9 @@ export default async function pyloadProxyHandler(req, res) { if (data?.error || status !== 200) { try { - return res.status(status).send(Buffer.from(data).toString()); + return res.status(status).send({error: {message: "HTTP error communicating with Plex API", data: Buffer.from(data).toString()}}); } catch (e) { - return res.status(status).send(data); + return res.status(status).send({error: {message: "HTTP error communicating with Plex API", data}}); } } @@ -95,7 +95,7 @@ export default async function pyloadProxyHandler(req, res) { } } catch (e) { logger.error(e); - return res.status(500).send(e.toString()); + return res.status(500).send({error: {message: `Error communicating with Plex API: ${e.toString()}`}}); } return res.status(400).json({ error: 'Invalid proxy service type' }); diff --git a/src/widgets/truenas/component.jsx b/src/widgets/truenas/component.jsx index 4244d8333..fd2fdbe79 100644 --- a/src/widgets/truenas/component.jsx +++ b/src/widgets/truenas/component.jsx @@ -41,8 +41,9 @@ export default function Component({ service }) { const { data: alertData, error: alertError } = useWidgetAPI(widget, "alerts"); const { data: statusData, error: statusError } = useWidgetAPI(widget, "status"); - if (alertError || statusError) { - return ; + if (alertError || alertData?.error || statusError || statusData?.error) { + const finalError = alertError ?? alertData?.error ?? statusError ?? statusData?.error; + return ; } if (!alertData || !statusData) { diff --git a/src/widgets/truenas/widget.js b/src/widgets/truenas/widget.js index 7269e36a1..4c479e9f3 100644 --- a/src/widgets/truenas/widget.js +++ b/src/widgets/truenas/widget.js @@ -14,6 +14,10 @@ const widget = { }, status: { endpoint: "system/info", + validate: [ + "loadavg", + "uptime_seconds" + ] }, }, }; diff --git a/src/widgets/tubearchivist/component.jsx b/src/widgets/tubearchivist/component.jsx index 5b5484436..503fb0faa 100644 --- a/src/widgets/tubearchivist/component.jsx +++ b/src/widgets/tubearchivist/component.jsx @@ -14,8 +14,9 @@ export default function Component({ service }) { const { data: channelsData, error: channelsError } = useWidgetAPI(widget, "channels"); const { data: playlistsData, error: playlistsError } = useWidgetAPI(widget, "playlists"); - if (downloadsError || videosError || channelsError || playlistsError) { - return ; + if (downloadsError || downloadsData?.error || videosError || videosData?.error || channelsError || channelsData?.error || playlistsError || playlistsData?.error) { + const finalError = downloadsError ?? downloadsData?.error ?? videosError ?? videosData?.error ?? channelsError ?? channelsData?.error ?? playlistsError ?? playlistsData?.error; + return ; } if (!downloadsData || !videosData || !channelsData || !playlistsData) { diff --git a/src/widgets/tubearchivist/widget.js b/src/widgets/tubearchivist/widget.js index c73070f00..6610bf123 100644 --- a/src/widgets/tubearchivist/widget.js +++ b/src/widgets/tubearchivist/widget.js @@ -7,15 +7,27 @@ const widget = { mappings: { downloads: { endpoint: "download", + validate: [ + "paginate", + ] }, videos: { endpoint: "video", + validate: [ + "paginate", + ] }, channels: { endpoint: "channel", + validate: [ + "paginate", + ] }, playlists: { endpoint: "playlist", + validate: [ + "paginate", + ] }, }, }; diff --git a/src/widgets/watchtower/component.jsx b/src/widgets/watchtower/component.jsx index 68c5531f6..2f683c1db 100644 --- a/src/widgets/watchtower/component.jsx +++ b/src/widgets/watchtower/component.jsx @@ -12,8 +12,9 @@ export default function Component({ service }) { const { data: watchData, error: watchError } = useWidgetAPI(widget, "watchtower"); - if (watchError || !watchData) { - return ; + if (watchError || watchData?.error) { + const finalError = watchError ?? watchData?.error; + return ; } if (!watchData) { diff --git a/src/widgets/watchtower/proxy.js b/src/widgets/watchtower/proxy.js index 2d54928c6..b37fc5f8b 100644 --- a/src/widgets/watchtower/proxy.js +++ b/src/widgets/watchtower/proxy.js @@ -33,15 +33,16 @@ export default async function watchtowerProxyHandler(req, res) { if (status !== 200 || !data) { logger.error("Error getting data from WatchTower: %d. Data: %s", status, data); + return res.status(status).json({error: {message: `HTTP Error ${status}`, url, data}}); } - const cleanData = data.toString().split("\n").filter(s => s.startsWith("watchtower")) + const cleanData = data.toString().split("\n").filter(s => s.startsWith("watchtower")); const jsonRes = {} cleanData.map(e => e.split(" ")).forEach(strArray => { const [key, value] = strArray jsonRes[key] = value - }) + }); if (contentType) res.setHeader("Content-Type", contentType); return res.status(status).send(jsonRes);