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
46
47
48
49
50
#[macro_use]
extern crate snafu;

extern crate indexmap;
extern crate ommui_file_loading;
extern crate xio_instructionset;
extern crate xio_jobset;

use snafu::{Backtrace, Snafu};

pub mod convert;

pub type Result<T, E = Error> = std::result::Result<T, E>;

/// The error kinds.
#[derive(Debug, Snafu)]
pub enum Error {
    /// IO error.
    #[snafu(display("Io error: {}", source))]
    Io {
        source: std::io::Error,
        backtrace: Backtrace,
    },

    /// Parameter count mismatch
    #[snafu(display(
        "Parameter names length {} not equal to parameters length {}",
        names,
        parameters
    ))]
    ParameterCountMismatch {
        names: usize,
        parameters: usize,
        backtrace: Backtrace,
    },

    /// Parameter not found
    #[snafu(display("Parameter with name {:?} not found", name))]
    ParameterNotFound { name: String, backtrace: Backtrace },

    /// Instruction not found
    #[snafu(display("Instruction with id {:?} not found", name))]
    InstructionNotFound { name: String, backtrace: Backtrace },

    #[snafu(display("{}", source))]
    OmmuiFileLoading {
        #[snafu(backtrace)]
        source: ommui_file_loading::Error,
    },
}