Skip to content

Commit

Permalink
fix: missing api key error handling (#2645)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan authored Apr 9, 2024
1 parent 9479beb commit c31a6ef
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/browser/extensions/engines/helpers/sse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function requestInference(
const data = await response.json()
const error = {
message: data.error?.message ?? 'Error occurred.',
code: data.error?.code ?? ErrorCode.Unknown,
code: data.error?.code ?? data.error?.type ?? ErrorCode.Unknown,
}
subscriber.error(error)
subscriber.complete()
Expand Down
2 changes: 2 additions & 0 deletions core/src/types/message/messageEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export enum ErrorCode {

InsufficientQuota = 'insufficient_quota',

InvalidRequestError = 'invalid_request_error',

Unknown = 'unknown',
}

Expand Down
1 change: 1 addition & 0 deletions web/screens/Chat/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
case ErrorCode.Unknown:
return 'Apologies, something’s amiss!'
case ErrorCode.InvalidApiKey:
case ErrorCode.InvalidRequestError:
return (
<span>
Invalid API key. Please check your API key from{' '}
Expand Down

0 comments on commit c31a6ef

Please sign in to comment.