fix: better error handling

This commit is contained in:
Fredrik Burmester
2024-08-16 18:51:11 +02:00
parent d2ff29a370
commit 329072a7a8

View File

@@ -3,10 +3,10 @@ import { AxiosError } from "axios";
import { getAuthHeaders } from "../jellyfin"; import { getAuthHeaders } from "../jellyfin";
interface ReportPlaybackProgressParams { interface ReportPlaybackProgressParams {
api: Api | null | undefined; api: Api;
sessionId: string | null | undefined; sessionId: string;
itemId: string | null | undefined; itemId: string;
positionTicks: number | null | undefined; positionTicks: number;
} }
/** /**
@@ -21,10 +21,12 @@ export const reportPlaybackProgress = async ({
itemId, itemId,
positionTicks, positionTicks,
}: ReportPlaybackProgressParams): Promise<void> => { }: ReportPlaybackProgressParams): Promise<void> => {
if (!api || !sessionId || !itemId || positionTicks == null) { console.info(
throw new Error("Missing required parameters for reportPlaybackProgress"); "Reporting playback progress:",
} sessionId,
itemId,
positionTicks,
);
try { try {
await api.axiosInstance.post( await api.axiosInstance.post(
`${api.basePath}/Sessions/Playing/Progress`, `${api.basePath}/Sessions/Playing/Progress`,