errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code")
display("http request returned an unsuccessful status code: {}", e)
}
}
};
}
errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code")
display("http request returned an unsuccessful status code: {}", e)
}
}
};
}
#[test] fn smoke_test_6() {
error_chain! {
errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code")
display("http request returned an unsuccessful status code: {}", e)
}
}
};
}
errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code")
display("http request returned an unsuccessful status code: {}", e)
}
}
};
}
errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code")
display("http request returned an unsuccessful status code: {}", e)
}
}
let _: Result<()> = Err(fmt::Error).chain_err(|| ""); let _: Result<()> = Err(Error::from_kind(ErrorKind::Test)).chain_err(|| "");
}
/// Verify that an error chain is extended one by `Error::chain_err`, with /// the new error added to the end. #[test] fn error_chain_err() {
error_chain! {
errors {
Test
}
}
let base = Error::from(ErrorKind::Test); let ext = base.chain_err(|| "Test passes");
iflet Error(ErrorKind::Msg(_), _) = ext { // pass
} else {
panic!("The error should be wrapped. {:?}", ext);
}
}
// Note: foreign errors must be `pub` because they appear in the // signature of the public foreign_link_error_path #[derive(Debug)] pubstruct ForeignError {
cause: ForeignErrorCause,
}
/// Since the `types` declaration is a list of symbols, check if we /// don't change their meaning or order. #[test] fn types_declarations() {
error_chain! {
types {
MyError, MyErrorKind, MyResultExt, MyResult;
}
}
MyError::from_kind(MyErrorKind::Msg("".into()));
let err: Result<(), ::std::io::Error> = Ok(());
MyResultExt::chain_err(err, || "").unwrap();
let _: MyResult<()> = Ok(());
}
#[test] /// Calling chain_err over a `Result` containing an error to get a chained error /// and constructing a MyError directly, passing it an error should be equivalent. fn rewrapping() { use std::env::VarError::{self, NotPresent, NotUnicode};
let result_a_from_func: Result<String, _> = Err(VarError::NotPresent); let result_b_from_func: Result<String, _> = Err(VarError::NotPresent);
let our_error_a = result_a_from_func.map_err(|e| match e {
NotPresent => MyError::with_chain(e, "env var wasn't provided"),
NotUnicode(_) => MyError::with_chain(e, "env var was borkæ–‡å—化ã"),
});
let our_error_b = result_b_from_func.or_else(|e| match e {
NotPresent => Err(e).chain_err(|| "env var wasn't provided"),
NotUnicode(_) => Err(e).chain_err(|| "env var was borkæ–‡å—化ã"),
});
errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code"),
display("http request returned an unsuccessful status code: {}", e)
}
}
};
}
errors {
HttpStatus(e: u32) {
description("http request returned an unsuccessful status code"),
display("http request returned an unsuccessful status code: {}", e),
}
}
};
}
let x = Error::from_kind(ErrorKind::MyMsg("some string".into())); // This would fail to compile if we generate a `Msg` variant match *x.kind() {
ErrorKind::MyMsg(_) => {}
ErrorKind::__Nonexhaustive {} => {}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.31 Sekunden
(vorverarbeitet am 2026-06-17)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.