use std::path::PathBuf;
use thiserror::Error;
pub type Result<T, E = DnoiseError> = std::result::Result<T, E>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum DnoiseError {
#[error("{0} is not a Bruker .d folder (missing analysis.tdf / analysis.tdf_bin)")]
NotADotD(PathBuf),
#[error("output {0} already exists (pass force to overwrite)")]
OutputExists(PathBuf),
#[error("opening frame data: {0}")]
OpenFrames(String),
#[error("reading metadata: {0}")]
Metadata(String),
#[error("reading frame {index}: {message}")]
FrameRead {
index: usize,
message: String,
},
#[error(transparent)]
Decode(#[from] DecodeError),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("database error: {0}")]
Sqlite(#[from] rusqlite::Error),
#[error("cancelled")]
Cancelled,
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum DecodeError {
#[error("record shorter than header")]
ShortRecord,
#[error("invalid total_byte_count {0}")]
InvalidByteCount(usize),
#[error("decompressed blob not u32-aligned")]
Misaligned,
#[error("scan_count {scan_count} exceeds blob length {len}")]
ScanCountOverflow {
scan_count: usize,
len: usize,
},
#[error("zstd decompression failed: {0}")]
Zstd(#[source] std::io::Error),
}