quake_files/
error.rs

1//! Defines error and result types for this library.
2
3use std::io;
4use walkdir;
5
6/// Result of most things in this library that use IO or can fail for other reasons.
7pub type QResult<T> = Result<T, QError>;
8
9/// Error types.
10#[derive(Debug)]
11pub enum QError {
12    /// See `std::io::Error`.
13    IoError(io::Error),
14    /// Invalid LMP file.
15    InvalidLmp,
16    /// Palette bigger than 256 colors
17    InvalidPaletteSize,
18    /// Wrong magic bytes in the file header.
19    BadMagicBytes,
20    /// Invalid filename for a PAK file.
21    BadFileName,
22    /// Unable to find the given file in the PAK.
23    FileNotFound,
24    /// See `walkdir::Error`.
25    WalkDirError(walkdir::Error),
26    /// Palette does not contain given color.
27    ColorNotInPalette,
28}
29
30impl From<io::Error> for QError {
31    fn from(err: io::Error) -> QError {
32        QError::IoError(err)
33    }
34}
35
36impl From<walkdir::Error> for QError {
37    fn from(err: walkdir::Error) -> QError {
38        QError::WalkDirError(err)
39    }
40}