* Checks whether a value provides the name and message of an Error. * @param error - The value to inspect. * @returns Whether the value can be used as an Error.
(error: unknown)
| 141 | * @returns Whether the value can be used as an Error. |
| 142 | */ |
| 143 | function isErrorLike(error: unknown): error is Error { |
| 144 | return ( |
| 145 | error instanceof Error || |
| 146 | (typeof error === 'object' && |
| 147 | error !== null && |
| 148 | typeof (error as Error).name === 'string' && |
| 149 | typeof (error as Error).message === 'string') |
| 150 | ) |
| 151 | } |