Skip to content

Commit

Permalink
Remove statusText error check to broaden compatibility (#1001)
Browse files Browse the repository at this point in the history
  • Loading branch information
cah4a authored Aug 13, 2024
1 parent a2f69d9 commit e4dd603
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/horizon/call_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface EventSourceOptions<T> {
const anyGlobal = global as any;
type Constructable<T> = 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<EventSource> = anyGlobal.EventSource ??
anyGlobal.window?.EventSource ??
Expand Down Expand Up @@ -181,7 +181,7 @@ export class CallBuilder<
return es;
};



createEventSource();
return () => {
Expand Down Expand Up @@ -399,19 +399,19 @@ export class CallBuilder<
*/
// eslint-disable-next-line require-await
private async _handleNetworkError(error: NetworkError): Promise<void> {
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));
}
}
}
}

0 comments on commit e4dd603

Please sign in to comment.