Fall back to direct execution when the daemon is unavailable.
(cli: &Cli, ws_url: &str, error: &anyhow::Error)
| 934 | |
| 935 | /// Fall back to direct execution when the daemon is unavailable. |
| 936 | async fn run_direct_fallback(cli: &Cli, ws_url: &str, error: &anyhow::Error) -> Result<()> { |
| 937 | eprintln!("Warning: daemon unavailable ({error}), running directly"); |
| 938 | let cmd_name = cli.command_name(); |
| 939 | let start = std::time::Instant::now(); |
| 940 | let result = run_direct(cli, ws_url).await; |
| 941 | let duration = start.elapsed(); |
| 942 | match &result { |
| 943 | Ok(r) => { |
| 944 | telemetry::log_command(cmd_name, duration, true, r.error_code); |
| 945 | print_result(r); |
| 946 | } |
| 947 | Err(e) => { |
| 948 | let code = e |
| 949 | .downcast_ref::<error::CliError>() |
| 950 | .map(|ce| ce.code().code()); |
| 951 | telemetry::log_command(cmd_name, duration, false, code); |
| 952 | } |
| 953 | } |
| 954 | result.map(|_| ()) |
| 955 | } |
| 956 | |
| 957 | /// Direct execution without daemon (fallback). |
| 958 | async fn run_direct(cli: &Cli, ws_url: &str) -> Result<result::CommandResult> { |
no test coverage detected