Skip to content

Commit

Permalink
Fix JS error surfaced in the UI (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlarew authored Aug 7, 2023
1 parent c4fc213 commit 5e6866a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions chat-ui/src/services/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,27 @@ export default class ConversationService {
if (moreToStream && retryCount++ < maxRetries) {
return err.retryAfter;
}
(err.data.json() as Promise<{ error: string }>).then((errorBody) => {
throw new Error(errorBody.error);
});
}
if (err instanceof Error) {
// Past this point we no longer want to retry, so
// rethrow to stop the operation and let the error
// bubble up to the caller.
if (!err.data) {
throw new Error(err.message);
}

if (err.data instanceof Response) {
const errorBodyPromise = err.data.json() as Promise<{
error: string;
}>;
errorBodyPromise.then((errorBody) => {
throw new Error(errorBody.error);
});
} else {
throw new Error(err.message);
}
} else if (err instanceof Error) {
throw new Error(err.message);
}
throw err; // rethrow to stop the operation
throw err;
},
});
}
Expand Down

0 comments on commit 5e6866a

Please sign in to comment.