2026-05-28 21:37:23 +03:00
|
|
|
import { NonRetryableError } from '$shared/api/queryClient';
|
|
|
|
|
|
2026-04-05 09:04:47 +03:00
|
|
|
/**
|
|
|
|
|
* Thrown when the network request to the proxy API fails.
|
|
|
|
|
* Wraps the underlying fetch error (timeout, DNS failure, connection refused, etc.).
|
|
|
|
|
*/
|
|
|
|
|
export class FontNetworkError extends Error {
|
|
|
|
|
readonly name = 'FontNetworkError';
|
|
|
|
|
|
|
|
|
|
constructor(public readonly cause?: unknown) {
|
|
|
|
|
super('Failed to fetch fonts from proxy API');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Thrown when the proxy API returns a response with an unexpected shape.
|
2026-05-28 21:37:23 +03:00
|
|
|
* Extends NonRetryableError because schema mismatches are not transient —
|
|
|
|
|
* retrying will produce the same failure and only delay surfacing the bug.
|
2026-04-05 09:04:47 +03:00
|
|
|
*
|
|
|
|
|
* @property field - The name of the field that failed validation (e.g. `'response'`, `'response.fonts'`).
|
|
|
|
|
* @property received - The actual value received at that field, for debugging.
|
|
|
|
|
*/
|
2026-05-28 21:37:23 +03:00
|
|
|
export class FontResponseError extends NonRetryableError {
|
2026-04-05 09:04:47 +03:00
|
|
|
readonly name = 'FontResponseError';
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public readonly field: string,
|
|
|
|
|
public readonly received: unknown,
|
|
|
|
|
) {
|
|
|
|
|
super(`Invalid proxy API response: ${field}`);
|
|
|
|
|
}
|
|
|
|
|
}
|