Skip to content

Commit

Permalink
fix(errors): pass message through to APIConnectionError (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 9, 2024
1 parent 25f1b59 commit 5a34316
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class APIError extends OpenAIError {
headers: Headers | undefined,
) {
if (!status) {
return new APIConnectionError({ cause: castToError(errorResponse) });
return new APIConnectionError({ message, cause: castToError(errorResponse) });
}

const error = (errorResponse as Record<string, any>)?.['error'];
Expand Down Expand Up @@ -113,7 +113,7 @@ export class APIUserAbortError extends APIError {
export class APIConnectionError extends APIError {
override readonly status: undefined = undefined;

constructor({ message, cause }: { message?: string; cause?: Error | undefined }) {
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
super(undefined, undefined, message || 'Connection error.', undefined);
// in some environments the 'cause' property is already declared
// @ts-ignore
Expand Down

0 comments on commit 5a34316

Please sign in to comment.