Skip to content

Commit b8dc229

Browse files
fix(errors): pass message through to APIConnectionError (openai#1050)
1 parent 25f1b59 commit b8dc229

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/error.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class APIError extends OpenAIError {
6161
headers: Headers | undefined,
6262
) {
6363
if (!status) {
64-
return new APIConnectionError({ cause: castToError(errorResponse) });
64+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
6565
}
6666

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

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

0 commit comments

Comments
 (0)