Struct one_err::OneErr [−][src]
pub struct OneErr(_);
Expand description
OneErr to rule them all. See crate docs for usage.
Implementations
Create a new OneErr error instance with a message.
Get the &str kind associated with this instance.
This can be more descriptive where io_kind()
or errno()
might return ‘Other’.
Set an additional data field on this OneErr. Will panic on reserved names: “error”, “os”, “source”, “backtrace”, “message”.
Get the message associated with this instance, or empty string.
Methods from Deref<Target = Error>
Returns the OS error that this error represents (if any).
If this Error
was constructed via last_os_error
or
from_raw_os_error
, then this function will return Some
, otherwise
it will return None
.
Examples
use std::io::{Error, ErrorKind};
fn print_os_error(err: &Error) {
if let Some(raw_os_err) = err.raw_os_error() {
println!("raw OS error: {:?}", raw_os_err);
} else {
println!("Not an OS error");
}
}
fn main() {
// Will print "raw OS error: ...".
print_os_error(&Error::last_os_error());
// Will print "Not an OS error".
print_os_error(&Error::new(ErrorKind::Other, "oh no!"));
}
Returns a reference to the inner error wrapped by this error (if any).
If this Error
was constructed via new
then this function will
return Some
, otherwise it will return None
.
Examples
use std::io::{Error, ErrorKind};
fn print_error(err: &Error) {
if let Some(inner_err) = err.get_ref() {
println!("Inner error: {:?}", inner_err);
} else {
println!("No inner error");
}
}
fn main() {
// Will print "No inner error".
print_error(&Error::last_os_error());
// Will print "Inner error: ...".
print_error(&Error::new(ErrorKind::Other, "oh no!"));
}
Returns the corresponding ErrorKind
for this error.
Examples
use std::io::{Error, ErrorKind};
fn print_error(err: Error) {
println!("{:?}", err.kind());
}
fn main() {
// Will print "Uncategorized".
print_error(Error::last_os_error());
// Will print "AddrInUse".
print_error(Error::new(ErrorKind::AddrInUse, "oh no!"));
}
Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl !RefUnwindSafe for OneErr
impl !UnwindSafe for OneErr
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.