diff options
| author | owenofbrien <[email protected]> | 2025-08-12 11:51:21 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-12 16:51:21 +0000 |
| commit | 5d1d40fa2ef418ef707aa29215594a8f22e4dadb (patch) | |
| tree | b568415dda36cc3dcffce6c39a8a38663a497b10 | |
| parent | 804c181ac4a3dc1c4971a5b8a643421bbe697f3d (diff) | |
Fix: log api response error status codes (#6015)
Co-authored-by: Gaurav <[email protected]>
| -rw-r--r-- | packages/core/src/core/loggingContentGenerator.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/core/src/core/loggingContentGenerator.ts b/packages/core/src/core/loggingContentGenerator.ts index 305b19a4..13bd6918 100644 --- a/packages/core/src/core/loggingContentGenerator.ts +++ b/packages/core/src/core/loggingContentGenerator.ts @@ -28,6 +28,19 @@ import { import { ContentGenerator } from './contentGenerator.js'; import { toContents } from '../code_assist/converter.js'; +interface StructuredError { + status: number; +} + +export function isStructuredError(error: unknown): error is StructuredError { + return ( + typeof error === 'object' && + error !== null && + 'status' in error && + typeof (error as StructuredError).status === 'number' + ); +} + /** * A decorator that wraps a ContentGenerator to add logging to API calls. */ @@ -85,6 +98,9 @@ export class LoggingContentGenerator implements ContentGenerator { prompt_id, this.config.getContentGeneratorConfig()?.authType, errorType, + isStructuredError(error) + ? (error as StructuredError).status + : undefined, ), ); } |
