diff options
Diffstat (limited to 'packages/cli/src/utils/errors.ts')
| -rw-r--r-- | packages/cli/src/utils/errors.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/cli/src/utils/errors.ts b/packages/cli/src/utils/errors.ts new file mode 100644 index 00000000..7708895a --- /dev/null +++ b/packages/cli/src/utils/errors.ts @@ -0,0 +1,18 @@ +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'; + } + } +}
\ No newline at end of file |
