diff options
Diffstat (limited to 'lib/core/libimagerror/src/errors.rs')
-rw-r--r-- | lib/core/libimagerror/src/errors.rs | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/lib/core/libimagerror/src/errors.rs b/lib/core/libimagerror/src/errors.rs index a1373d91..e74eedaf 100644 --- a/lib/core/libimagerror/src/errors.rs +++ b/lib/core/libimagerror/src/errors.rs @@ -17,88 +17,98 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // -#[derive(Debug, Clone, Eq, PartialEq, Fail)] -pub enum ErrorMsg { - #[fail(display = "IO Error")] - IO, +use thiserror::Error; - #[fail(display = "Locking error")] +pub type Result<T> = ::std::result::Result<T, Error>; + +#[derive(Debug, Error)] +pub enum Error { + #[error("IO error")] + IO(#[from] ::std::io::Error), + + #[error("Unknown IO error")] + UnknownIO, + + #[error("Locking error")] LockError, - #[fail(display = "UTF8 error")] - UTF8Error, + #[error("Locking error")] + PoisonError, + + #[error("UTF8 error")] + UTF8Error(#[from] std::str::Utf8Error), - #[fail(display = "Error in external process")] + #[error("Error in external process")] ExternalProcessError, - #[fail(display = "File Error")] + #[error("File Error")] FileError, - #[fail(display = "File not copied")] + #[error("File not copied")] FileNotCopied, - #[fail(display = "File not created")] + #[error("File not created")] FileNotCreated, - #[fail(display = "File not found")] + #[error("File not found")] FileNotFound, - #[fail(display = "Fail not removed")] + #[error("Fail not removed")] FileNotRemoved, - #[fail(display = "Fail not renamed")] + #[error("Fail not renamed")] FileNotRenamed, - #[fail(display = "File not seeked")] + #[error("File not seeked")] FileNotSeeked, - #[fail(display = "File not written")] + #[error("File not written")] FileNotWritten, - #[fail(display = "Directory not created")] + #[error("Directory not created")] DirNotCreated, - #[fail(display = "Formatting error")] - FormatError, + #[error("Formatting error")] + FormatError(#[from] std::fmt::Error), - #[fail(display = "ID is locked")] + #[error("ID is locked")] IdLocked, - #[fail(display = "Error while converting values")] + #[error("Error while converting values")] ConversionError, - #[fail(display = "Entry exists already: {}", _0)] + #[error("Entry exists already: {0}")] EntryAlreadyExists(String), - #[fail(display = "Entry not found: {}", _0)] + #[error("Entry not found: {0}")] EntryNotFound(String), - #[fail(display = "Entry header error")] + #[error("Entry header error")] EntryHeaderError, - #[fail(display = "Entry header type error")] + #[error("Entry header type error")] EntryHeaderTypeError, - #[fail(display = "Entry header type error at '{}', expected '{}'", _0, _1)] + #[error("Entry header type error at '{0}', expected '{1}'")] EntryHeaderTypeError2(&'static str, &'static str), - #[fail(display = "Entry header read error")] + #[error("Entry header read error")] EntryHeaderReadError, - #[fail(display = "Entry header write error")] + #[error("Entry header write error")] EntryHeaderWriteError, - #[fail(display = "Entry header field missing: {}", _0)] + #[error("Entry header field missing: {0}")] EntryHeaderFieldMissing(&'static str), - #[fail(display = "Toml deserialization error")] + #[error("Toml deserialization error")] TomlDeserError, - #[fail(display = "Toml querying error")] + #[error("Toml querying error")] TomlQueryError, } |