diff options
| author | Evan Senter <[email protected]> | 2025-04-19 19:45:42 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-19 19:45:42 +0100 |
| commit | 3fce6cea27d3e6129d6c06e528b62e1b11bf7094 (patch) | |
| tree | 244b8e9ab94f902d65d4bda8739a6538e377ed17 /packages/server/src/utils/errors.ts | |
| parent | 0c9e1ef61be7db53e6e73b7208b649cd8cbed6c3 (diff) | |
Starting to modularize into separate cli / server packages. (#55)
* Starting to move a lot of code into packages/server
* More of the massive refactor, builds and runs, some issues though.
* Fixing outstanding issue with double messages.
* Fixing a minor UI issue.
* Fixing the build post-merge.
* Running formatting.
* Addressing comments.
Diffstat (limited to 'packages/server/src/utils/errors.ts')
| -rw-r--r-- | packages/server/src/utils/errors.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/server/src/utils/errors.ts b/packages/server/src/utils/errors.ts new file mode 100644 index 00000000..15417c83 --- /dev/null +++ b/packages/server/src/utils/errors.ts @@ -0,0 +1,24 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +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'; + } + } +} |
