Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
Something went wrong. Try again.
1.4 kB · 40 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940import type { Response } from 'superagent';
import { findCauseByFunc } from "../../utils/ErrorUtils.ts";import { addKnownErrorConstructor } from 'serialize-error';
export type UpstreamErrorOptions = ErrorOptions & { showStopper?: boolean, response?: Response, responseBody?: object | string };
export class UpstreamError extends Error {
override name = 'UpstreamError'; showStopper: boolean = false; response?: Response responseBody?: object | string
constructor(message: string, options?: UpstreamErrorOptions | undefined) { super(message, options); const {showStopper = false, response, responseBody} = options ?? {}; this.showStopper = showStopper; this.response = response; this.responseBody = responseBody; }}
export const hasUpstreamError = (err: any, showStopping?: boolean): boolean => { return findUpstreamError(err, showStopping) !== undefined;}
export const findUpstreamError = (err: any, showStopping?: boolean): UpstreamError | undefined => { return findCauseByFunc(err, (e) => { if (e instanceof UpstreamError) { if (showStopping === undefined) { return true; } else { return e.showStopper === showStopping; } } return false; });}addKnownErrorConstructor(UpstreamError, () => new UpstreamError(''))