[][src]Enum gen_epub_book::Error

pub enum Error {
    Io {
        desc: &'static str,
        op: &'static str,
        more: Option<&'static str>,
    },
    Parse {
        tp: &'static str,
        wher: &'static str,
        more: Option<&'static str>,
    },
    FileNotFound {
        who: &'static str,
        path: PathBuf,
    },
    WrongFileState {
        what: &'static str,
        path: PathBuf,
    },
    WrongElementAmount {
        element: &'static str,
        actual: usize,
        relation: &'static str,
        bound: usize,
    },
    RequiredElementMissing(&'static str),
}

Enum representing all possible ways the application can fail.

Variants

Io

An I/O error occured.

This includes higher-level I/O errors like FS ones.

Fields of Io

desc: &'static str

The file the I/O operation regards.

op: &'static str

The failed operation.

This should be lowercase and imperative ("create", "open").

more: Option<&'static str>

Additional data.

Parse

A parsing error occured.

Fields of Parse

tp: &'static str

What failed to parse.

Something like "URL", "datetime".

wher: &'static str

Where the thing that failed to parse would go, were it to parese properly.

more: Option<&'static str>

Additional data.

FileNotFound

A requested file doesn't exist.

Fields of FileNotFound

who: &'static str

What requested the file.

path: PathBuf

The file that should exist.

WrongFileState

A path is in a wrong state.

Fields of WrongFileState

what: &'static str

What the file is not.

path: PathBuf

The file that should be.

WrongElementAmount

An incorrect amount of book elements.

Fields of WrongElementAmount

element: &'static str

The element's name.

actual: usize

Current amount.

relation: &'static str

How it should be.

bound: usize

What it should be.

RequiredElementMissing(&'static str)

A required book element is missing.

Methods

impl Error[src]

pub fn print_error<W: Write>(&self, err_out: &mut W)[src]

Write the error message to the specified output stream.

Examples

let mut out = Vec::new();
Error::Io {
    desc: "network",
    op: "write",
    more: Some("full buffer"),
}.print_error(&mut out);
assert_eq!(String::from_iter(out.iter().map(|&i| i as char)),
           "Writing network failed: full buffer.\n".to_string());

pub fn exit_value(&self) -> i32[src]

Get the executable exit value from an Error instance.

Examples

assert_eq!(Error::Io {
    desc: "",
    op: "",
    more: None,
}.exit_value(), 1);

Trait Implementations

impl PartialEq<Error> for Error[src]

impl Clone for Error[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for Error[src]

impl Debug for Error[src]

impl Hash for Error[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for Error

impl Sync for Error

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Erased for T[src]