* Converts an unknown rejection reason to an Error-compatible value. * @param error - The rejected value. * @returns The existing error-like value, or an Error wrapping the rejection.
(error: unknown)
| 128 | * @returns The existing error-like value, or an Error wrapping the rejection. |
| 129 | */ |
| 130 | function normalizeError(error: unknown): Error { |
| 131 | if (isErrorLike(error)) { |
| 132 | return error |
| 133 | } |
| 134 | |
| 135 | return new Error(String(error), { cause: error }) |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Checks whether a value provides the name and message of an Error. |
no test coverage detected