Esri/arcgis-rest-js

Expose Response Headers on ArcgisError object for status != 200

开放

#1,181 创建于 2024年11月8日

 (4 条评论) (0 个反应) (1 位负责人)TypeScript (126 个派生)auto 404
enhancementhelp wanted

仓库指标

星标
 (389 个星标)
PR 合并指标
 (平均合并 11天 4小时) (30 天内合并 5 个 PR)

描述

Describe the problem

We had a support request with AGOL and they need the response headers, there is no way to get them from this package without patching the module (which we are attempting) When a status code 500/503 (non 200) error is returned the response headers are not exposed via the error object.

Describe the proposed solution

We are seeing if this will work (in my simulations it appeared to). Tweaking this code here seemed to do it.

https://github.com/Esri/arcgis-rest-js/blob/main/packages/arcgis-rest-request/src/request.ts#L424

            const { status, statusText, headers } = response;
            const { message, details } = jsonError.error;
            const formattedMessage = `${message}. ${
              details ? details.join(" ") : ""
            }`.trim();

            throw new ArcGISRequestError(
              formattedMessage,
              `HTTP ${status} ${statusText}`,
              {body: jsonError, headers: [...headers]},
              url,
              options
            );
          })

Alternatives considered

No response

Additional Information

No response

贡献者指南