use thiserror::Error;
#[derive(Debug, Error)]
pub enum FormatError {
#[error("{0}")]
Parse(String),
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("NBT io error: {0}")]
NbtIo(#[from] quartz_nbt::io::NbtIoError),
#[error("NBT structure error: {0}")]
NbtRepr(#[from] quartz_nbt::NbtReprError),
#[error("zip error: {0}")]
Zip(#[from] zip::result::ZipError),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("bincode error: {0}")]
Bincode(#[from] bincode::Error),
#[error("slice conversion error: {0}")]
TryFromSlice(#[from] std::array::TryFromSliceError),
}
impl From<String> for FormatError {
fn from(s: String) -> Self {
FormatError::Parse(s)
}
}
impl From<&str> for FormatError {
fn from(s: &str) -> Self {
FormatError::Parse(s.to_string())
}
}
pub type Result<T> = std::result::Result<T, FormatError>;