Skip to content

Commit

Permalink
Fix deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Nov 6, 2024
1 parent cad2d5d commit 57f83bf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sentry-panic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! # Configuration
//!
//! The panic integration can be configured with an additional extractor, which
//! might optionally create a sentry `Event` out of a `PanicInfo`.
//! might optionally create a sentry `Event` out of a `PanicHookInfo`.
//!
//! ```
//! let integration = sentry_panic::PanicIntegration::default().add_extractor(|info| None);
Expand All @@ -19,7 +19,7 @@
#![warn(missing_docs)]
#![deny(unsafe_code)]

use std::panic::{self, PanicInfo};
use std::panic::{self, PanicHookInfo};
use std::sync::Once;

use sentry_backtrace::current_stacktrace;
Expand All @@ -31,7 +31,7 @@ use sentry_core::{ClientOptions, Integration};
/// This panic handler reports panics to Sentry. It also attempts to prevent
/// double faults in some cases where it's known to be unsafe to invoke the
/// Sentry panic handler.
pub fn panic_handler(info: &PanicInfo<'_>) {
pub fn panic_handler(info: &PanicHookInfo<'_>) {
sentry_core::with_integration(|integration: &PanicIntegration, hub| {
hub.capture_event(integration.event_from_panic_info(info));
if let Some(client) = hub.client() {
Expand All @@ -40,7 +40,7 @@ pub fn panic_handler(info: &PanicInfo<'_>) {
});
}

type PanicExtractor = dyn Fn(&PanicInfo<'_>) -> Option<Event<'static>> + Send + Sync;
type PanicExtractor = dyn Fn(&PanicHookInfo<'_>) -> Option<Event<'static>> + Send + Sync;

/// The Sentry Panic handler Integration.
#[derive(Default)]
Expand Down Expand Up @@ -75,7 +75,7 @@ impl Integration for PanicIntegration {
}

/// Extract the message of a panic.
pub fn message_from_panic_info<'a>(info: &'a PanicInfo<'_>) -> &'a str {
pub fn message_from_panic_info<'a>(info: &'a PanicHookInfo<'_>) -> &'a str {
match info.payload().downcast_ref::<&'static str>() {
Some(s) => s,
None => match info.payload().downcast_ref::<String>() {
Expand All @@ -95,7 +95,7 @@ impl PanicIntegration {
#[must_use]
pub fn add_extractor<F>(mut self, f: F) -> Self
where
F: Fn(&PanicInfo<'_>) -> Option<Event<'static>> + Send + Sync + 'static,
F: Fn(&PanicHookInfo<'_>) -> Option<Event<'static>> + Send + Sync + 'static,
{
self.extractors.push(Box::new(f));
self
Expand All @@ -104,7 +104,7 @@ impl PanicIntegration {
/// Creates an event from the given panic info.
///
/// The stacktrace is calculated from the current frame.
pub fn event_from_panic_info(&self, info: &PanicInfo<'_>) -> Event<'static> {
pub fn event_from_panic_info(&self, info: &PanicHookInfo<'_>) -> Event<'static> {
for extractor in &self.extractors {
if let Some(event) = extractor(info) {
return event;
Expand Down

0 comments on commit 57f83bf

Please sign in to comment.