Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(network): preserve XHR error response bodies (#7963)

OTime-Coder4e50005a6e77
diff --git a/packages/network/src/services/http/implementations/__tests__/xhr.spec.ts b/packages/network/src/services/http/implementations/__tests__/xhr.spec.ts
index f291aabb9b..387d7c314e 100644
--- a/packages/network/src/services/http/implementations/__tests__/xhr.spec.ts
+++ b/packages/network/src/services/http/implementations/__tests__/xhr.spec.ts
@@ -161,7 +161,7 @@ describe('XHRHTTPImplementation', () => {
xhrInstances[0].statusText = 'Server Error';
xhrInstances[0].responseText = '{"ok":false}';
xhrInstances[0].emit('load');
- await expect(statusError).rejects.toMatchObject({ status: 500, statusText: 'Server Error' });
+ await expect(statusError).rejects.toMatchObject({ status: 500, statusText: 'Server Error', error: { ok: false } });
const jsonError = new Promise((resolve, reject) => {
impl.send(createRequest('json')).subscribe({ next: resolve, error: reject });
diff --git a/packages/network/src/services/http/implementations/xhr.ts b/packages/network/src/services/http/implementations/xhr.ts
index 3972b0fb7d..4230d33a1b 100644
--- a/packages/network/src/services/http/implementations/xhr.ts
+++ b/packages/network/src/services/http/implementations/xhr.ts
@@ -113,7 +113,7 @@ export class XHRHTTPImplementation implements IHTTPImplementation {
} else {
const e = new HTTPResponseError({
request,
- error,
+ error: error ?? body,
headers,
status,
statusText,