(error: unknown)
| 50 | } |
| 51 | |
| 52 | export function extractAppCommandError(error: unknown): AppCommandError | null { |
| 53 | const direct = parseErrorObject(error) |
| 54 | if (direct) return direct |
| 55 | |
| 56 | const errorObject = asObject(error) |
| 57 | const message = normalizeString(errorObject?.message) |
| 58 | if (!message) return null |
| 59 | |
| 60 | try { |
| 61 | const parsed = JSON.parse(message) |
| 62 | return parseErrorObject(parsed) |
| 63 | } catch { |
| 64 | return null |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Must mirror `AppErrorCode::NotAGitRepository` in src-tauri/src/app_error.rs. |
| 69 | // If the backend enum ever renames, both sides must change together. |
no test coverage detected