(error: unknown)
| 123 | } |
| 124 | |
| 125 | export function errorMessage(error: unknown): string { |
| 126 | if (error instanceof Error) { |
| 127 | if (error.message) return error.message |
| 128 | if (error.name) return error.name |
| 129 | } |
| 130 | |
| 131 | if (isRecord(error) && typeof error.message === "string" && error.message) { |
| 132 | return error.message |
| 133 | } |
| 134 | |
| 135 | if (isRecord(error) && isRecord(error.data) && typeof error.data.message === "string" && error.data.message) { |
| 136 | return error.data.message |
| 137 | } |
| 138 | |
| 139 | const text = String(error) |
| 140 | if (text && text !== "[object Object]") return text |
| 141 | |
| 142 | const formatted = errorFormat(error) |
| 143 | if (formatted) return formatted |
| 144 | return "unknown error" |
| 145 | } |
| 146 | |
| 147 | export function errorData(error: unknown) { |
| 148 | if (error instanceof Error) { |
no test coverage detected