@shopify/shopify-app-remix
Version:
Shopify Remix - to simplify the building of Shopify Apps with Remix
1 lines • 2.45 kB
Source Map (JSON)
{"version":3,"file":"handle-client-error.mjs","sources":["../../../../../../../src/server/authenticate/admin/helpers/handle-client-error.ts"],"sourcesContent":["import {HttpResponseError} from '@shopify/shopify-api';\n\nimport type {HandleAdminClientError} from '../../../clients/admin/types';\nimport {HandleClientErrorOptions} from '../strategies/types';\n\nexport function handleClientErrorFactory({\n request,\n onError,\n}: HandleClientErrorOptions): HandleAdminClientError {\n return async function handleClientError({\n error,\n params,\n session,\n }): Promise<never> {\n if (error instanceof HttpResponseError !== true) {\n params.logger.debug(\n `Got a response error from the API: ${error.message}`,\n {shop: session.shop},\n );\n throw error;\n }\n\n params.logger.debug(\n `Got an HTTP response error from the API: ${error.message}`,\n {\n shop: session.shop,\n code: error.response.code,\n statusText: error.response.statusText,\n body: JSON.stringify(error.response.body),\n },\n );\n\n if (onError) {\n await onError({request, session, error});\n }\n\n // forward a minimal copy of the upstream HTTP response instead of an Error:\n throw new Response(JSON.stringify(error.response.body), {\n status: error.response.code,\n headers: {\n 'Content-Type': error.response.headers!['Content-Type'] as string,\n },\n });\n };\n}\n"],"names":[],"mappings":";;SAKgB,wBAAwB,CAAC,EACvC,OAAO,EACP,OAAO,GACkB,EAAA;IACzB,OAAO,eAAe,iBAAiB,CAAC,EACtC,KAAK,EACL,MAAM,EACN,OAAO,GACR,EAAA;AACC,QAAA,IAAI,KAAK,YAAY,iBAAiB,KAAK,IAAI,EAAE;AAC/C,YAAA,MAAM,CAAC,MAAM,CAAC,KAAK,CACjB,CAAA,mCAAA,EAAsC,KAAK,CAAC,OAAO,EAAE,EACrD,EAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAC,CACrB;AACD,YAAA,MAAM,KAAK;QACb;QAEA,MAAM,CAAC,MAAM,CAAC,KAAK,CACjB,4CAA4C,KAAK,CAAC,OAAO,CAAA,CAAE,EAC3D;YACE,IAAI,EAAE,OAAO,CAAC,IAAI;AAClB,YAAA,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;AACzB,YAAA,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU;YACrC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC1C,SAAA,CACF;QAED,IAAI,OAAO,EAAE;YACX,MAAM,OAAO,CAAC,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAC,CAAC;QAC1C;;AAGA,QAAA,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;AACtD,YAAA,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;AAC3B,YAAA,OAAO,EAAE;gBACP,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAQ,CAAC,cAAc,CAAW;AAClE,aAAA;AACF,SAAA,CAAC;AACJ,IAAA,CAAC;AACH;;;;"}