mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 07:30:52 -07:00
18 lines
584 B
TypeScript
18 lines
584 B
TypeScript
|
|
export function isNodeError(error: unknown): error is NodeJS.ErrnoException {
|
||
|
|
return error instanceof Error && 'code' in error;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getErrorMessage(error: unknown): string {
|
||
|
|
if (error instanceof Error) {
|
||
|
|
return error.message;
|
||
|
|
} else {
|
||
|
|
// Attempt to convert the non-Error value to a string for logging
|
||
|
|
try {
|
||
|
|
const errorMessage = String(error);
|
||
|
|
return errorMessage;
|
||
|
|
} catch {
|
||
|
|
// If String() itself fails (highly unlikely)
|
||
|
|
return 'Failed to get error details';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|