Improve error handling when Navidrome fails

This commit is contained in:
simojenki
2021-08-22 13:12:59 +10:00
parent 06db0c2088
commit 8dc98ee1a5
4 changed files with 7 additions and 8 deletions

View File

@@ -367,7 +367,7 @@ export class Navidrome implements MusicService {
)
.then((json) => json["subsonic-response"])
.then((json) => {
if (isError(json)) throw json.error._message;
if (isError(json)) throw `Navidrome error:${json.error._message}`;
else return json as unknown as T;
});

View File

@@ -438,8 +438,7 @@ function server(
})
.catch((e: Error) => {
logger.error(
`Failed fetching image ${type}/${id}/size/${size}: ${e.message}`,
e
`Failed fetching image ${type}/${id}/size/${size}`, { cause: e }
);
return res.status(500).send();
});

View File

@@ -162,7 +162,7 @@ export function autoDiscoverySonos(sonosSeedHost?: string): Sonos {
}
})
.catch((e) => {
logger.error(`Failed looking for sonos devices ${e}`);
logger.error(`Failed looking for sonos devices`, { cause: e });
return [];
});
};