error-kit 0.1.0

A comprehensive error handling library for Rust applications
Documentation
use std::io::Error as IoError;

use super::types::CommonError;

impl CommonError {
    /// Helper to create I/O errors with custom messages.
    pub fn io_error(message: &str) -> Self {
        CommonError::Io(IoError::other(message))
    }

    /// Helper for cache lock errors.
    pub fn cache_lock() -> Self {
        CommonError::CacheLock
    }

    /// Helper for serialization errors.
    pub fn serialization(detail: &'static str) -> Self {
        CommonError::Serialization(detail)
    }

    /// Helper for deserialization errors.
    pub fn deserialization(detail: &'static str) -> Self {
        CommonError::Deserialization(detail)
    }

    /// Helper for unsupported file type errors.
    pub fn unsupported_file_type(detail: &'static str) -> Self {
        CommonError::UnsupportedFileType(detail)
    }

    /// Helper for data not found errors.
    pub fn data_not_found() -> Self {
        CommonError::DataNotFound
    }

    /// Helper for unable to refresh data errors.
    pub fn unable_to_fresh_data() -> Self {
        CommonError::UnableToFreshData
    }

    /// Helper for stale internal none errors.
    pub fn stale_internal_none() -> Self {
        CommonError::StaleInternalNone
    }

    /// Helper for timeout errors.
    pub fn timeout() -> Self {
        CommonError::Timeout
    }

    /// Helper for filename errors.
    pub fn filename_error() -> Self {
        CommonError::FilenameError
    }

    /// Helper for invalid filename encoding errors.
    pub fn invalid_filename_encoding() -> Self {
        CommonError::InvalidFilenameEncoding
    }

    /// Helper for missing timestamp separator errors.
    pub fn missing_timestamp_separator() -> Self {
        CommonError::MissingTimestampSeparator
    }

    /// Helper for missing file extension errors.
    pub fn missing_file_extension() -> Self {
        CommonError::MissingFileExtension
    }

    /// Helper for timestamp parse errors.
    pub fn timestamp_parse_error() -> Self {
        CommonError::TimestampParseError
    }
}