Skip to content

Conversation

szokeasaurusrex
Copy link
Member

This change improves Sentry CLI's panic hook to make panic messages more user-friendly.

The panic message generated by the hook emphasizes that panics are internal errors in the Sentry CLI, and the message directs users to our bug report issue form. The message also always includes a stack backtrace, regardless of whether RUST_BACKTRACE is set.

The new panic message looks like the following:

🔥 Internal Error in Sentry CLI 🔥

Uh-oh! 😬 Sentry CLI has just crashed due to an internal error. Please open a bug report issue at https://github.com/getsentry/sentry-cli/issues/new?template=BUG_REPORT.yml. 🐞

🔬 Technical Details 🔬

thread 'main' panicked at src/commands/sourcemaps/upload.rs:422:5:
test error

Stack Backtrace:
   0: std::backtrace_rs::backtrace::libunwind::trace
             at /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[... truncated ...]

This change also removes the dependency on the backtrace crate, and renames the function which sets the panic hook from init_backtrace to set_panic_hook.

This change improves Sentry CLI's panic hook to make panic messages more user-friendly.

The panic message generated by the hook emphasizes that panics are internal errors in the Sentry CLI, and the message directs users to our bug report issue form. The message also always includes a stack backtrace, regardless of whether `RUST_BACKTRACE` is set.

The new panic message looks like the following:

```
🔥 Internal Error in Sentry CLI 🔥

Uh-oh! 😬 Sentry CLI has just crashed due to an internal error. Please open a bug report issue at https://github.com/getsentry/sentry-cli/issues/new?template=BUG_REPORT.yml. 🐞

🔬 Technical Details 🔬

thread 'main' panicked at src/commands/sourcemaps/upload.rs:422:5:
test error

Stack Backtrace:
   0: std::backtrace_rs::backtrace::libunwind::trace
             at /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1: std::backtrace_rs::backtrace::trace_unsynchronized
             at /rustc/9fc6b43126469e3858e2fe86cafb4f0fd5068869/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
[... truncated ...]
```
Copy link
Contributor

@loewenheim loewenheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good!

@szokeasaurusrex szokeasaurusrex merged commit 4278c53 into master Jan 23, 2025
14 checks passed
@szokeasaurusrex szokeasaurusrex deleted the szokeasaurusrex/panic-handler branch January 23, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants