aboutsummaryrefslogtreecommitdiff
path: root/src/error.rs
blob: 8c2f09633f96e9f4c9fcc88449e92ea453cee7c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::{error, fmt};

pub type OBIResult<T> = Result<T, OBIError>;

#[derive(Debug)]
pub enum OBIError {
    Encode,
    Decode,
    Image,
}

impl fmt::Display for OBIError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            OBIError::Encode => writeln!(f, "Encoding error"),
            OBIError::Decode => writeln!(f, "Decoding error"),
            OBIError::Image => writeln!(f, "Image manipulation error"),
        }
    }
}

impl error::Error for OBIError {}

#[derive(Debug)]
enum Encode {
    Metadata(MetadataError),
    ChunkError(u32),
}

#[derive(Debug)]
enum Decode {
    Metadata(MetadataError),
    ChunkError(u32),
}

#[derive(Debug)]
enum MetadataError {
    VersionError,
    FileSizeError,
    DataOffsetError,
    WidthError,
    HeightError,
    CompressionTypeError,
    PostCompressionSizeError,
}