Function sentry::configure_scope [] [src]

pub fn configure_scope<F, R>(f: F) -> R where
    R: Default,
    F: FnOnce(&mut Scope) -> R, 

Invokes a function that can modify the current scope.

The function is passed a mutable reference to the Scope so that modifications can be performed. Because there might currently not be a scope or client active it's possible that the callback might not be called at all. As a result of this the return value of this closure must have a default that is returned in such cases.

Example

sentry::configure_scope(|scope| {
    scope.set_user(Some(sentry::User {
        username: Some("john_doe".into()),
        ..Default::default()
    }));
});

Panics

While the scope is being configured accessing scope related functionality is not permitted. In this case a wide range of panics will be raised. It's unsafe to call into sentry::bind_client or similar functions from within the callback as a result of this.