Function sentry::with_scope [] [src]

pub fn with_scope<F, R>(f: F) -> R where
    F: FnOnce() -> R, 

A callback based alternative to using push_scope.

This that might look a bit nicer and is more consistent with some other language integerations.

Example

sentry::with_scope(|| {
    sentry::configure_scope(|scope| {
        scope.set_user(Some(sentry::User {
            username: Some("john_doe".into()),
            ..Default::default()
        }));
    });
    panic!("Something went wrong!");
});