tismith / exitfailure Goto Github PK
View Code? Open in Web Editor NEWHelpers for easily using failure::Error and others as return types in main() while still giving human-readable error messages.
License: Apache License 2.0
Helpers for easily using failure::Error and others as return types in main() while still giving human-readable error messages.
License: Apache License 2.0
When running cargo test
on master I get:
test test_backtrace ... FAILED
failures:
---- test_backtrace stdout ----
thread 'test_backtrace' panicked at 'Unexpected stderr, failed var.contains("stack backtrace")
└── var as str: Error: this is some context
Info: caused by root cause failure
0: failure::backtrace::internal::InternalBacktrace::new
at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/internal.rs:46:44
1: failure::backtrace::Backtrace::new
at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/mod.rs:121:35
2: <failure::error::error_impl::ErrorImpl as core::convert::From<F>>::from
at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error/error_impl.rs:19:17
3: <failure::error::Error as core::convert::From<F>>::from
at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error/mod.rs:36:18
4: failure::error_message::err_msg
at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error_message.rs:12:5
5: example::some_fn
at examples/example.rs:20:21
6: example::main
at examples/example.rs:16:8
7: core::ops::function::FnOnce::call_once
at /builddir/build/BUILD/rustc-1.54.0-src/library/core/src/ops/function.rs:227:5
8: std::sys_common::backtrace::__rust_begin_short_backtrace
at /builddir/build/BUILD/rustc-1.54.0-src/library/std/src/sys_common/backtrace.rs:125:18
9: std::rt::lang_start::{{closure}}
at /builddir/build/BUILD/rustc-1.54.0-src/library/std/src/rt.rs:49:18
10: std::rt::lang_start_internal
11: std::rt::lang_start
at /builddir/build/BUILD/rustc-1.54.0-src/library/std/src/rt.rs:48:5
12: main
13: __libc_start_main
14: _start
command=`"/home/dcavalca/fedora-wip/resctl-demo/r2/exitfailure/target/debug/examples/example"`
code=1
stdout=```""```
stderr=```"Error: this is some context\nInfo: caused by root cause failure\n 0: failure::backtrace::internal::InternalBacktrace::new\n at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/internal.rs:46:44\n 1: failure::backtrace::Backtrace::new\n at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/backtrace/mod.rs:121:35\n 2: <failure::error::error_impl::ErrorImpl as core::convert::From<F>>::from\n at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error/error_impl.rs:19:17\n 3: <failure::error::Error as core::convert::From<F>>::from\n at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error/mod.rs:36:18\n 4: failure::error_message::err_msg\n at /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.8/src/error_message.rs:12:5\n 5: example::some_fn\n at examples/example.rs:20:21\n 6: example::main\n at examples/example.rs:16:8\n 7: core::ops::function::FnOnce::call_once\n at /builddir/build/BUILD/rustc-1.54.0-src/library/core/src/ops/function.rs:227:5\n 8: std::sys_common::backtrace::__rust_begin_short_backtrace\n at /builddir/build/BUILD/rustc-1.54.0-src/library/std/src/sys_common/backtrace.rs:125:18\n 9: std::rt::lang_start::{{closure}}\n at /builddir/build/BUILD/rustc-1.54.0-src/library/std/src/rt.rs:49:18\n 10: std::rt::lang_start_internal\n 11: std::rt::lang_start\n at /builddir/build/BUILD/rustc-1.54.0-src/library/std/src/rt.rs:48:5\n 12: main\n 13: __libc_start_main\n 14: _start\n\n"```
', /home/dcavalca/.cargo/registry/src/github.com-1ecc6299db9ec823/assert_cmd-1.0.8/src/assert.rs:124:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
test_backtrace
test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s
Is there something like this that can be used with anyhow/thiserror? :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.