affaan-m/ECC · warning · anyhow::Error

exited with

Error message

{program} exited with {status}

What it means

Notification delivery runs an external command (the configured notification program) and checks its exit status. If the process launches but exits non-zero, this error surfaces the program name and its `ExitStatus` (e.g. ' exited with: exit status: 1'). It means the notification command itself failed, not that launching failed.

Solutions

  1. Run the notification command manually with the same arguments to see its real error output.
  2. Fix the exit path of the script so it returns 0 on success.
  3. Check PATH and environment (dbus/display) for the process context; use absolute binary paths in the script.
  4. Log stderr from the command; if notifications are optional, consider treating failure as non-fatal in the caller.

Example fix

// before
#!/bin/sh
notify-send "$1"   # fails on headless, exits 1
// after
#!/bin/sh
command -v notify-send >/dev/null 2>&1 && notify-send "$1"
exit 0
Defensive patterns

Strategy: try-catch

Validate before calling

// before configuring, check the program exists
if which::which("notify-send").is_err() {
    eprintln!("notification program not installed");
}

Try / catch

match try_notify(&event) {
    Err(e) if e.to_string().contains("exited with") => {
        log::warn!("notification command failed (non-fatal): {e}");
    }
    Err(e) => log::error!("notify dispatch failed: {e}"),
    Ok(()) => {}
}

Prevention

When it happens

Trigger: The configured notification command exits non-zero — e.g. a script that prints to a closed pipe, `notify-send` unavailable via PATH inside the script, or a webhook-posting script receiving an HTTP error and exiting 1.

Common situations: Custom notification scripts with bugs; PATH differences when the daemon runs under systemd vs interactive shell; scripts failing when the desktop session/dbus is absent (headless server).

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/bcb82a72d922b76b. Report an issue: GitHub.

Appendix: source

Thrown at ecc2/src/notifications.rs:395

            "content": message,
            "allowed_mentions": {
                "parse": []
            }
        }),
    }
}

#[cfg(not(test))]
fn run_notification_command(program: &str, args: &[String]) -> Result<()> {
    let status = std::process::Command::new(program)
        .args(args)
        .status()
        .with_context(|| format!("launch {program}"))?;

    if status.success() {
        Ok(())
    } else {
        anyhow::bail!("{program} exited with {status}");
    }
}

#[cfg(test)]
fn run_notification_command(_program: &str, _args: &[String]) -> Result<()> {
    Ok(())
}

#[cfg(not(test))]
fn send_webhook_request(target: &WebhookTarget, payload: serde_json::Value) -> Result<()> {
    let agent = ureq::Agent::config_builder()
        .timeout_connect(Some(std::time::Duration::from_secs(5)))
        .timeout_recv_response(Some(std::time::Duration::from_secs(5)))
        .build()
        .new_agent();
    let response = agent
        .post(&target.url)
        .send_json(payload)

View on GitHub (pinned to 8321021c54)