2025-07-09 10:18:15 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
import type { StructuredError } from '../core/turn.js';
|
2025-08-13 17:57:11 +00:00
|
|
|
|
2025-07-09 10:18:15 -04:00
|
|
|
export interface ApiError {
|
|
|
|
|
error: {
|
|
|
|
|
code: number;
|
|
|
|
|
message: string;
|
|
|
|
|
status: string;
|
|
|
|
|
details: unknown[];
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isApiError(error: unknown): error is ApiError {
|
|
|
|
|
return (
|
|
|
|
|
typeof error === 'object' &&
|
|
|
|
|
error !== null &&
|
|
|
|
|
'error' in error &&
|
|
|
|
|
typeof (error as ApiError).error === 'object' &&
|
|
|
|
|
'message' in (error as ApiError).error
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isStructuredError(error: unknown): error is StructuredError {
|
|
|
|
|
return (
|
|
|
|
|
typeof error === 'object' &&
|
|
|
|
|
error !== null &&
|
|
|
|
|
'message' in error &&
|
|
|
|
|
typeof (error as StructuredError).message === 'string'
|
|
|
|
|
);
|
|
|
|
|
}
|