use thiserror::Error;
pub type Result<T> = std::result::Result<T, CloudError>;
#[derive(Error, Debug)]
pub enum CloudError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Invalid point cloud format: {0}")]
FormatError(String),
#[error("Algorithm failed: {0}")]
AlgorithmError(String),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("Memory allocation failed: {0}")]
MemoryError(String),
#[error("Search operation failed: {0}")]
SearchError(String),
#[error("Serialization error: {0}")]
SerializationError(#[from] serde_json::Error),
#[error("{0}")]
Custom(String),
}
impl CloudError {
pub fn format_error<S: Into<String>>(msg: S) -> Self {
CloudError::FormatError(msg.into())
}
pub fn algorithm_error<S: Into<String>>(msg: S) -> Self {
CloudError::AlgorithmError(msg.into())
}
pub fn invalid_parameter<S: Into<String>>(msg: S) -> Self {
CloudError::InvalidParameter(msg.into())
}
pub fn memory_error<S: Into<String>>(msg: S) -> Self {
CloudError::MemoryError(msg.into())
}
pub fn search_error<S: Into<String>>(msg: S) -> Self {
CloudError::SearchError(msg.into())
}
pub fn custom<S: Into<String>>(msg: S) -> Self {
CloudError::Custom(msg.into())
}
}