UNPKG

@shopify/shopify-app-remix

Version:

Shopify Remix - to simplify the building of Shopify Apps with Remix

29 lines (26 loc) 1.12 kB
import { HttpResponseError } from '@shopify/shopify-api'; function handleClientErrorFactory({ request, onError, }) { return async function handleClientError({ error, params, session, }) { if (error instanceof HttpResponseError !== true) { params.logger.debug(`Got a response error from the API: ${error.message}`); throw error; } params.logger.debug(`Got an HTTP response error from the API: ${error.message}`, { code: error.response.code, statusText: error.response.statusText, body: JSON.stringify(error.response.body), }); if (onError) { await onError({ request, session, error }); } // forward a minimal copy of the upstream HTTP response instead of an Error: throw new Response(JSON.stringify(error.response.body), { status: error.response.code, headers: { 'Content-Type': error.response.headers['Content-Type'], }, }); }; } export { handleClientErrorFactory }; //# sourceMappingURL=handle-client-error.mjs.map