Skip to content

Commit 694c64f

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix(errors): pass message through to APIConnectionError (#313)
1 parent 14613c4 commit 694c64f

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
@@ -49,7 +49,7 @@ export class APIError extends PromptFoundryError {
4949
headers: Headers | undefined,
5050
) {
5151
if (!status) {
52-
return new APIConnectionError({ cause: castToError(errorResponse) });
52+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
5353
}
5454

5555
const error = errorResponse as Record<string, any>;
@@ -101,7 +101,7 @@ export class APIUserAbortError extends APIError {
101101
export class APIConnectionError extends APIError {
102102
override readonly status: undefined = undefined;
103103

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

0 commit comments

Comments
 (0)