error_kit/
constructors.rs

1use std::io::Error as IoError;
2
3use super::types::CommonError;
4
5impl CommonError {
6    /// Helper to create I/O errors with custom messages.
7    pub fn io_error(message: &str) -> Self {
8        CommonError::Io(IoError::other(message))
9    }
10
11    /// Helper for cache lock errors.
12    pub fn cache_lock() -> Self {
13        CommonError::CacheLock
14    }
15
16    /// Helper for serialization errors.
17    pub fn serialization(detail: &'static str) -> Self {
18        CommonError::Serialization(detail)
19    }
20
21    /// Helper for deserialization errors.
22    pub fn deserialization(detail: &'static str) -> Self {
23        CommonError::Deserialization(detail)
24    }
25
26    /// Helper for unsupported file type errors.
27    pub fn unsupported_file_type(detail: &'static str) -> Self {
28        CommonError::UnsupportedFileType(detail)
29    }
30
31    /// Helper for data not found errors.
32    pub fn data_not_found() -> Self {
33        CommonError::DataNotFound
34    }
35
36    /// Helper for unable to refresh data errors.
37    pub fn unable_to_fresh_data() -> Self {
38        CommonError::UnableToFreshData
39    }
40
41    /// Helper for stale internal none errors.
42    pub fn stale_internal_none() -> Self {
43        CommonError::StaleInternalNone
44    }
45
46    /// Helper for timeout errors.
47    pub fn timeout() -> Self {
48        CommonError::Timeout
49    }
50
51    /// Helper for filename errors.
52    pub fn filename_error() -> Self {
53        CommonError::FilenameError
54    }
55
56    /// Helper for invalid filename encoding errors.
57    pub fn invalid_filename_encoding() -> Self {
58        CommonError::InvalidFilenameEncoding
59    }
60
61    /// Helper for missing timestamp separator errors.
62    pub fn missing_timestamp_separator() -> Self {
63        CommonError::MissingTimestampSeparator
64    }
65
66    /// Helper for missing file extension errors.
67    pub fn missing_file_extension() -> Self {
68        CommonError::MissingFileExtension
69    }
70
71    /// Helper for timestamp parse errors.
72    pub fn timestamp_parse_error() -> Self {
73        CommonError::TimestampParseError
74    }
75}