mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-15 01:10:35 +00:00
Add detailed Error component for service widgets
This commit is contained in:
parent
7b7740563e
commit
21017e4716
37 changed files with 113 additions and 113 deletions
|
@ -14,8 +14,9 @@ export default function Component({ service }) {
|
|||
refreshInterval: 5000,
|
||||
});
|
||||
|
||||
if (plexAPIError) {
|
||||
return <Container error={t("widget.api_error")} />;
|
||||
if (plexAPIError || plexData?.error) {
|
||||
const finalError = plexAPIError ?? plexData.error;
|
||||
return <Container error={finalError} />;
|
||||
}
|
||||
|
||||
if (!plexData) {
|
||||
|
|
|
@ -44,7 +44,7 @@ async function fetchFromPlexAPI(endpoint, widget) {
|
|||
|
||||
if (status !== 200) {
|
||||
logger.error("HTTP %d communicating with Plex. Data: %s", status, data.toString());
|
||||
return [status, data.toString()];
|
||||
return [status, data];
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -65,6 +65,11 @@ export default async function plexProxyHandler(req, res) {
|
|||
logger.debug("Getting streams from Plex API");
|
||||
let streams;
|
||||
let [status, apiData] = await fetchFromPlexAPI("/status/sessions", widget);
|
||||
|
||||
if (status !== 200) {
|
||||
return res.status(status).json({error: {message: "HTTP error communicating with Plex API", data: apiData}});
|
||||
}
|
||||
|
||||
if (apiData && apiData.MediaContainer) {
|
||||
streams = apiData.MediaContainer._attributes.size;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue