You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//! Reduce the effort for users to report panics back to you
6
4
//!
7
-
//! ## Why?
8
-
//! When you're building a CLI, polish is super important. Even though Rust is
9
-
//! pretty great at safety, it's not unheard of to access the wrong index in a
10
-
//! vector or have an assert fail somewhere.
5
+
//! You can still get the raw output by either:
6
+
//! - Running a debug build
7
+
//! - Setting `RUST_BACKTRACE=1`
11
8
//!
12
-
//! When an error eventually occurs, you probably will want to know about it. So
13
-
//! instead of just providing an error message on the command line, we can create a
14
-
//! call to action for people to submit a report.
9
+
//! ## Example
15
10
//!
16
-
//! This should empower people to engage in communication, lowering the chances
17
-
//! people might get frustrated. And making it easier to figure out what might be
18
-
//! causing bugs.
19
-
//!
20
-
//! ### Default Output
21
-
//!
22
-
//! ```txt
23
-
//! thread 'main' panicked at 'oops', examples/main.rs:2:3
24
-
//! note: Run with `RUST_BACKTRACE=1` for a backtrace.
11
+
//! Add to your `fn main()`:
12
+
//! ```rust
13
+
//! human_panic::setup_panic!();
25
14
//! ```
26
15
//!
27
-
//! ### Human-Panic Output
28
-
//!
16
+
//! When run locally in a release build:
29
17
//! ```txt
30
-
//! Well, this is embarrassing.
31
-
//!
32
-
//! human-panic had a problem and crashed. To help us diagnose the problem you can send us a crash report.
18
+
//! my-program had a problem and crashed. To help us diagnose the problem you can send us a crash report.
33
19
//!
34
20
//! We have generated a report file at "/var/folders/zw/bpfvmq390lv2c6gn_6byyv0w0000gn/T/report-8351cad6-d2b5-4fe8-accd-1fcbf4538792.toml". Submit an issue or email with the subject of "human-panic Crash Report" and include the report as an attachment.
35
21
//!
@@ -39,6 +25,13 @@
39
25
//! We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.
40
26
//!
41
27
//! Thank you kindly!
28
+
//! ```
29
+
//!
30
+
//! Traditional output:
31
+
//! ```txt
32
+
//! thread 'main' panicked at 'oops', examples/main.rs:2:3
33
+
//! note: Run with `RUST_BACKTRACE=1` for a backtrace.
34
+
//! ```
42
35
43
36
#![cfg_attr(docsrs, feature(doc_cfg))]
44
37
#![warn(clippy::print_stderr)]
@@ -58,7 +51,16 @@ pub use panic::handle_dump;
58
51
pubuse panic::print_msg;
59
52
pubuse panic::setup_panic;
60
53
61
-
/// Initialize [`Metadata`]
54
+
/// Collect Cargo [`Metadata`]
55
+
///
56
+
/// ## Example
57
+
///
58
+
/// ```rust
59
+
/// use human_panic::metadata;
60
+
///
61
+
/// let metadata = metadata!()
62
+
/// .support("- Open a support request by email to support@mycompany.com");
63
+
/// ```
62
64
#[macro_export]
63
65
macro_rules! metadata {
64
66
() => {{
@@ -69,25 +71,27 @@ macro_rules! metadata {
69
71
}};
70
72
}
71
73
72
-
/// `human-panic` initialisation macro
73
-
///
74
-
/// You can either call this macro with no arguments `setup_panic!()` or
75
-
/// with a Metadata struct, if you don't want the error message to display
76
-
/// the values used in your `Cargo.toml` file.
77
-
///
78
-
/// The Metadata struct can't implement `Default` because of orphan rules, which
79
-
/// means you need to provide all fields for initialisation.
74
+
/// Register `human-panic`
80
75
///
81
76
/// The macro should be called from within a function, for example as the first line of the
0 commit comments