use thiserror::Error;
#[derive(Debug, Error)]
pub enum IgraphError {
#[error("invalid argument: {0}")]
InvalidArgument(String),
#[error("vertex {id} out of range (graph has {n} vertices)")]
VertexOutOfRange {
id: u32,
n: u32,
},
#[error("edge {id} out of range (graph has {m} edges)")]
EdgeOutOfRange {
id: u32,
m: u32,
},
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("parse error at line {line}: {message}")]
Parse {
line: usize,
message: String,
},
#[error("unsupported: {0}")]
Unsupported(&'static str),
#[error("did not converge after {iters} iterations (last residual {residual})")]
DidNotConverge {
iters: usize,
residual: f64,
},
#[error("internal error: {0}")]
Internal(&'static str),
}
pub type IgraphResult<T> = std::result::Result<T, IgraphError>;