use std::io;
use std::net::SocketAddr;
use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(
"{addr} is not a loopback address; hazine serves on localhost only \
(reach it through an SSH tunnel)"
)]
NotLoopback { addr: SocketAddr },
#[error("init file {}: {source}", path.display())]
InitFile { path: PathBuf, source: io::Error },
#[error("something is already listening on {addr}")]
AddrInUse { addr: SocketAddr },
#[error("starting {}: {source}", program.display())]
Spawn { program: PathBuf, source: io::Error },
#[error("{} is not DuckDB 2.0 or later (it reports {found:?})", program.display())]
UnsupportedVersion { program: PathBuf, found: String },
#[error("DuckDB exited {count} times in a row before Quack was listening; giving up")]
GaveUp { count: u32 },
#[error("hazine setup must run as root (try sudo, or --dry-run)")]
NotRoot,
#[error("{0}")]
Unsupported(&'static str),
#[error("{name}: {reason}")]
InvalidSetting { name: &'static str, reason: String },
#[error(
"{name} is not set: give it as a flag or environment variable, or run setup in a terminal"
)]
MissingSetting { name: String },
#[error("{program} failed ({status}): {detail}")]
Command {
program: String,
status: String,
detail: String,
},
#[error("{0}")]
Tunnel(String),
#[error("the lake does not attach with these settings: {0}")]
LakeCheck(String),
#[error(transparent)]
Io(#[from] io::Error),
}