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
//! Custom error types.
//!
//! Unfortunately we can only define one error type using the ``error_type!`` macro in here, see
//! https://github.com/DanielKeep/rust-error-type/issues/2.

use redis::RedisError;
use r2d2::InitializationError;
use std::io;
use std::borrow::Cow;


/// A ``SpaceapiServerError`` wraps general problems that can occur in the SpaceAPI server.
error_type! {
    #[derive(Debug)]
    pub enum SpaceapiServerError {
        Redis(RedisError) {
            cause;
        },
        R2d2(InitializationError) {
            cause;
        },
        IoError(io::Error) {
            cause;
        },
        Message(Cow<'static, str>) {
            desc (e) &**e;
            from (s: &'static str) s.into();
            from (s: String) s.into();
        },
    }
}