Files
tts-workshop/packages/tts/src/errors.ts
T

35 lines
922 B
TypeScript

/** Errors thrown by the TTS fetcher. */
export class TtsError extends Error {
constructor(
message: string,
readonly status: number = 500,
) {
super(message);
this.name = 'TtsError';
}
}
/** The Steam API returned no details for the requested item. */
export class ItemNotFoundError extends TtsError {
constructor(id: string) {
super(`No Workshop item found for id ${id}`, 404);
this.name = 'ItemNotFoundError';
}
}
/** The item exists but has no downloadable `file_url`. */
export class NoFileError extends TtsError {
constructor(id: string) {
super(`Workshop item ${id} has no downloadable save file`, 404);
this.name = 'NoFileError';
}
}
/** The Steam API rejected the request (bad key, rate limit, etc.). */
export class SteamApiError extends TtsError {
constructor(message: string, status = 502) {
super(message, status);
this.name = 'SteamApiError';
}
}