Fix: log api response error status codes (#6015)

Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com>
This commit is contained in:
owenofbrien 2025-08-12 11:51:21 -05:00 committed by GitHub
parent 804c181ac4
commit 5d1d40fa2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 0 deletions

View File

@ -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,
),
);
}