GyulyVGC/sniffnet · error

Sniffnet error at [{file}:{line}]: {e}

Error message

Sniffnet error at [{file}:{line}]: {e}

What it means

This is Sniffnet's central error-logging message, emitted by the ErrorLogger trait's log_err() implementation (src/utils/error_logger.rs:16). Whenever any Result<T, E: Display> returned by a fallible operation is chained with .log_err(crate::location!()) and holds an Err, this line prints 'Sniffnet error at [file:line]: e' to stderr and then returns the Result unchanged. It is a diagnostic log, not a crash: the application decides downstream whether to propagate, ignore, or display the error.

Source

Thrown at src/utils/error_logger.rs:16

use std::fmt::Display;

/// Trait for logging errors in a unified way
pub trait ErrorLogger<T, E> {
    /// Log the error and its location
    #[allow(clippy::missing_errors_doc)]
    fn log_err(self, loc: Location) -> Result<T, E>;
}

impl<T, E: Display> ErrorLogger<T, E> for Result<T, E> {
    #[allow(clippy::print_stderr)]
    fn log_err(self, location: Location) -> Result<T, E> {
        if let Err(e) = &self {
            let file = location.file;
            let line = location.line;
            eprintln!("Sniffnet error at [{file}:{line}]: {e}");
            // in debug mode, panic on error
            #[cfg(debug_assertions)]
            #[allow(clippy::panic)]
            {
                panic!();
            }
        }

        self
    }
}

/// Struct to store the location in the code (file and line)
pub struct Location {
    pub file: &'static str,
    pub line: u32,
}

View on GitHub (pinned to 48b0575dc0)

Solutions

  1. Read the full line: the [file:line] suffix identifies the exact failing call site — open that source location to see which operation failed.
  2. Check capture privileges: on Linux run with sudo or `setcap cap_net_raw+ep` on the binary; on Windows install Npcap; on macOS allow the app in System Settings > Privacy & Security.
  3. Verify the config/logs directory exists and is writable by the current user (confy's default config path, plus the Sniffnet log file path).
  4. Re-run with `RUST_LOG`/release binary if the debug-mode panic (error 1) fires immediately after this log line and masks the diagnosis.
  5. If the error string is a pcap error (e.g. 'no such device', 'permissions problem'), fix the adapter selection or pcap runtime before touching app code.

Example fix

// before (fire-and-forget, error only logged via log_err and then dropped)
let _ = explorer.wait().log_err(crate::location!());

// after (inspect the failure instead of only logging it)
if let Err(e) = explorer.wait() {
    eprintln!("failed to wait on file explorer: {e}");
}
// or keep log_err but handle the returned Result explicitly:
let status = explorer.wait().log_err(crate::location!());
Defensive patterns

Strategy: try-catch

Try / catch

// log_err returns the Result unchanged — always inspect it instead of discarding
match risky_op().log_err(crate::location!()) {
    Ok(v) => use_value(v),
    Err(e) => {
        // e already printed as "Sniffnet error at [file:line]: {e}"
        recover_or_show_in_gui(e);
    }
}

Prevention

When it happens

Trigger: Calling any pcap/networking API wrapped with .log_err(crate::location!()) that fails, e.g. truncating the log file in src/cli/mod.rs:45, waiting on the file-explorer child process in src/cli/mod.rs:47, reopening the log file in src/cli/mod.rs:57, or applying the 'less 2' pause filter in src/networking/types/capture_context.rs:158. The exact file:line in the message is the captured Location passed via the location!() macro, pointing at the call site, not at error_logger.rs itself.

Common situations: Running `cargo run` / debug builds where the very same log_err call sites also panic (see error 1); insufficient OS permissions for raw packet capture (non-root without CAP_NET_RAW on Linux, Windows without Npcap, macOS without privilege); a read-only or missing config/log directory when the CLI log file is truncated; the spawned file explorer process failing to exit or to be waited on.

Related errors


AI-assisted analysis of GyulyVGC/sniffnet@48b0575dc0 (2026-08-16). Data as JSON: /api/errors/c56d42ab160a9b97. Report an issue: GitHub.