Skip to content

Commit 8cdd7ea

Browse files
committed
feat(errors): add request_id property (#769)
1 parent 56f4821 commit 8cdd7ea

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/error.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export class APIError extends OpenAIError {
1313
readonly param: string | null | undefined;
1414
readonly type: string | undefined;
1515

16+
readonly request_id: string | null | undefined;
17+
1618
constructor(
1719
status: number | undefined,
1820
error: Object | undefined,
@@ -22,6 +24,7 @@ export class APIError extends OpenAIError {
2224
super(`${APIError.makeMessage(status, error, message)}`);
2325
this.status = status;
2426
this.headers = headers;
27+
this.request_id = headers?.['x-request-id'];
2528

2629
const data = error as Record<string, any>;
2730
this.error = data;

0 commit comments

Comments
 (0)