From e4dd60350ac400f00190775b99795201fd6bd24c Mon Sep 17 00:00:00 2001 From: Sancha Kozlov Date: Tue, 13 Aug 2024 19:28:19 +0300 Subject: [PATCH] Remove `statusText` error check to broaden compatibility (#1001) --- src/horizon/call_builder.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/horizon/call_builder.ts b/src/horizon/call_builder.ts index 4006fbf46..e7fba4495 100644 --- a/src/horizon/call_builder.ts +++ b/src/horizon/call_builder.ts @@ -21,7 +21,7 @@ export interface EventSourceOptions { const anyGlobal = global as any; type Constructable = new (e: string) => T; // require("eventsource") for Node and React Native environment -/* eslint-disable global-require */ +/* eslint-disable global-require */ /* eslint-disable prefer-import/prefer-import-over-require */ const EventSource: Constructable = anyGlobal.EventSource ?? anyGlobal.window?.EventSource ?? @@ -181,7 +181,7 @@ export class CallBuilder< return es; }; - + createEventSource(); return () => { @@ -399,19 +399,19 @@ export class CallBuilder< */ // eslint-disable-next-line require-await private async _handleNetworkError(error: NetworkError): Promise { - if (error.response && error.response.status && error.response.statusText) { + if (error.response && error.response.status) { switch (error.response.status) { case 404: return Promise.reject( - new NotFoundError(error.response.statusText, error.response.data), + new NotFoundError(error.response.statusText ?? "Not Found", error.response.data), ); default: return Promise.reject( - new NetworkError(error.response.statusText, error.response.data), + new NetworkError(error.response.statusText ?? "Unknown", error.response.data), ); } } else { return Promise.reject(new Error(error.message)); } } -} \ No newline at end of file +}