blob: b1d968b1ce8693a77c8ff1d72b537660485d04de (
plain) (
blame)
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
|
use std::error;
use std::fmt;
pub type Result<T> = ::std::result::Result<T, Error>;
/// The error type returned by all libctru functions.
pub enum Error {
Os(i32),
}
impl From<i32> for Error {
fn from(err: i32) -> Self {
Error::Os(err)
}
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Os(err) => write!(f, "libctru result code: {:08X}", err),
}
}
}
// TODO: Expand libctru result code into human-readable error message
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Os(err) => write!(f, "libctru result code: 0x{:08X}", err),
}
}
}
impl error::Error for Error {
fn description(&self) -> &str {
"error originating from a libctru function"
}
}
|