Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 59x 59x 59x 59x 11x 11x 3x 13x 20x 20x 7x 5x | export class TranslationsError extends Error {
constructor(
public readonly statusCode: number,
public readonly statusMessage: string,
options?: ErrorOptions,
) {
super(statusMessage, options);
this.name = new.target.name;
}
}
export class UpstreamError extends TranslationsError {
constructor(
public readonly upstreamStatus: number | undefined,
cause?: unknown,
) {
super(502, "Upstream request failed", { cause });
}
}
export class TranslationsUnavailableError extends TranslationsError {
constructor(locale: string, cause?: unknown) {
super(502, `Translations unavailable for "${locale}"`, { cause });
}
}
export class UndefinedVendorError extends TranslationsError {
constructor(name: string | undefined, available: readonly string[]) {
super(
500,
`Requested vendor "${name ?? null}" does not exist. Available: ${available.join(", ")}`,
);
}
}
export class MisconfiguredVendorError extends TranslationsError {
constructor(
vendor: string,
public readonly problems: string[],
) {
super(500, `${vendor} is misconfigured: ${problems.join(", ")}`);
}
}
export class UndefinedLocaleError extends TranslationsError {
constructor(locale?: string) {
super(404, `Requested locale "${locale ?? null}" does not exist`);
}
}
export class UndefinedLocaleProviderError extends TranslationsError {
constructor(locale: string, vendorName: string) {
super(500, `Requested locale "${locale}" does not exist for ${vendorName}`);
}
}
|