UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

29 lines (28 loc) 836 B
/** * A custom Error type for errors that occur during a `fetch()` request. * Includes the `Response` object and optional response data for more detailed error analysis. * * @example * ```typescript * try { * const response = await fetch('/some/url') * * if (!response.ok) { * const data = await response.json(); // Attempt to parse JSON error data * throw new FetchError(response, data) * } * // ... process successful response * } catch (error) { * if (error instanceof FetchError) { * console.error("Fetch error:", error.message, error.response.status, error.data) * } else { * console.error("Other error:", error) * } * } * ``` */ export declare class FetchError extends Error { response: Response; data?: unknown; constructor(response: Response, data?: unknown); }