mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Improve error handling when Navidrome fails
This commit is contained in:
@@ -367,7 +367,7 @@ export class Navidrome implements MusicService {
|
|||||||
)
|
)
|
||||||
.then((json) => json["subsonic-response"])
|
.then((json) => json["subsonic-response"])
|
||||||
.then((json) => {
|
.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;
|
else return json as unknown as T;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -438,8 +438,7 @@ function server(
|
|||||||
})
|
})
|
||||||
.catch((e: Error) => {
|
.catch((e: Error) => {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Failed fetching image ${type}/${id}/size/${size}: ${e.message}`,
|
`Failed fetching image ${type}/${id}/size/${size}`, { cause: e }
|
||||||
e
|
|
||||||
);
|
);
|
||||||
return res.status(500).send();
|
return res.status(500).send();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ export function autoDiscoverySonos(sonosSeedHost?: string): Sonos {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
logger.error(`Failed looking for sonos devices ${e}`);
|
logger.error(`Failed looking for sonos devices`, { cause: e });
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ describe("Navidrome", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const token = await navidrome.generateToken({ username, password });
|
const token = await navidrome.generateToken({ username, password });
|
||||||
expect(token).toEqual({ message: "Wrong username or password" });
|
expect(token).toEqual({ message: "Navidrome error:Wrong username or password" });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -3387,7 +3387,7 @@ describe("Navidrome", () => {
|
|||||||
.then((it) => it as AuthSuccess)
|
.then((it) => it as AuthSuccess)
|
||||||
.then((it) => navidrome.login(it.authToken))
|
.then((it) => navidrome.login(it.authToken))
|
||||||
.then((it) => it.playlist(id))
|
.then((it) => it.playlist(id))
|
||||||
).rejects.toEqual("data not found");
|
).rejects.toEqual("Navidrome error:data not found");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -3742,7 +3742,7 @@ describe("Navidrome", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when there id doesnt exist", () => {
|
describe("when the id doesnt exist", () => {
|
||||||
it("should fail", async () => {
|
it("should fail", async () => {
|
||||||
const id = "idThatHasAnError";
|
const id = "idThatHasAnError";
|
||||||
|
|
||||||
@@ -3756,7 +3756,7 @@ describe("Navidrome", () => {
|
|||||||
.generateToken({ username, password })
|
.generateToken({ username, password })
|
||||||
.then((it) => it as AuthSuccess)
|
.then((it) => it as AuthSuccess)
|
||||||
.then((it) => navidrome.login(it.authToken))
|
.then((it) => navidrome.login(it.authToken))
|
||||||
.then((it) => it.similarSongs(id))).rejects.toEqual("data not found");
|
.then((it) => it.similarSongs(id))).rejects.toEqual("Navidrome error:data not found");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user