lemon_bugsnag_rs

Crates.iolemon_bugsnag_rs
lib.rslemon_bugsnag_rs
version0.1.2
created_at2025-10-22 19:25:48.111711+00
updated_at2025-10-22 20:38:13.057267+00
descriptionA library for interacting with the BugSnag error-reporting and sessions APIs.
homepagehttps://github.com/SpaceAceMonkey/lemon-bugsnag-rs
repositoryhttps://github.com/SpaceAceMonkey/lemon-bugsnag-rs
max_upload_size
id1896107
size662,420
(SpaceAceMonkey)

documentation

https://docs.rs/lemon_bugsnag_rs/latest/lemon_bugsnag_rs/

README

Examples

The quickest starts.

Error API, asynchronous client.

This example requires the

dep:tokio, async, error-client, and reqwest features.

// The ClientBuilder is the basis for most operations in this library.
use lemon_bugsnag_rs::common::builder::client_builder::ClientBuilder;
// This brings the `non_blocking()` function  of DeciderTraitAsync into
// scope. DeciderTraitSync and DeciderTraitAsync are the functions that
// allow you to choose whether you want a blocking or non-blocking client.
// This is required even if your chosen networking backend only offers one
// or the other.
use lemon_bugsnag_rs::common::traits::decider_trait_async::DeciderTraitAsync;
// This brings into scope the `build()` function of
// `BackendBuilderTraitAsync,` which is implemented by the builders that
// create and configure the asynchronous networking client you will use to
// send your BugSnag payload.
use lemon_bugsnag_rs::common::traits::backend_builder_trait_async::BackendBuilderTraitAsync;
// Provides the `send()` function for asynchronous backend clients.
use lemon_bugsnag_rs::common::traits::client_trait_async::ClientTraitAsync;

// To use the bundle rather than import each item separately:
// use lemon_bugsnag_rs::common::bundle::*;

// Start by retrieving a builder for BugSnag error-reporting API clients.
let mut cb = ClientBuilder::error();

cb.configure(
    "Your API key goes here",
    // An arbitrary string declaring an error class for this payload.
    "An error class for your message",
    "The error message you wish to record",
    // A string to identify the source of the error report. For example,
    // "Company Name mobile app," "web API," or, "lemon-bugsnag-rs," depending
    // on how you want to track errors.
    "Notifier name",
    "Notifier version",
    // Optional. Used to provide information about the language, libraries,
    // and frameworks used by the application reporting the error.
    "Rust 1.82.0 with lemon-bugsnag-rs",
    // Release stage of application reporting the error.
    "dev"
);

// Choose the `Reqwest` backend, which is the only currently-implemented
// networking backend that supports asynchronous operations. If additional
// asynchronous backends are implemented in the future, you would select
// one of them by replacing reqwest() with the appropriate backend name.
let mut client = cb.reqwest().non_blocking().build().unwrap();

// Send your payload. This must be done from an async context, such as
// an async function, or using `block_on()` or the equivalent from an
// async runtime.
match client.send().await {
    Ok(response) => {
        // Looks good. Do stuff.
    },
    Err(error) => {
        // A bummer has happened. Handle it.
    },
}

   

Error API, synchronous Reqwest client.

This example requires the

error-client, reqwest, and sync features.

use lemon_bugsnag_rs::common::bundle::*;

// Start by retrieving a builder for BugSnag error-reporting API clients.
let mut cb = ClientBuilder::error();

cb.configure(
    "Your API key goes here",
    // An arbitrary string declaring an error class for this payload.
    "An error class for your message",
    "The error message you wish to record",
    // A string to identify the source of the error report. For example,
    // "Company Name mobile app," "web API," or, "lemon-bugsnag-rs," depending
    // on how you want to track errors.
    "Notifier name",
    "Notifier version",
    // Optional. Used to provide information about the language, libraries,
    // and frameworks used by the application reporting the error.
    "Rust 1.82.0 with lemon-bugsnag-rs",
    // Release stage of application reporting the error.
    "dev"
);

// Choose the `Reqwest` non-blocking backend.
let mut client = cb.reqwest().blocking().build().unwrap();

// Send your payload.
match client.send() {
    Ok(response) => {
        // Looks good. Do stuff.
    },
    Err(error) => {
        // A bummer has happened. Handle it.
    }
}

   

Sessions API, asynchronous client

This example requires the

dep:tokio, session-client, reqwest, and async features.

use lemon_bugsnag_rs::common::bundle::*;

// Start by retrieving a builder for BugSnag error-reporting API clients.
let mut cb = ClientBuilder::session();

cb.configure(
    "Your API key goes here",
    // A string to identify the source of the error report. For example,
    // "Company Name mobile app," "web API," or, "lemon-bugsnag-rs," depending
    // on how you want to track errors.
    "A name to identify your application",
    "Notifier version",
    // Release stage of application reporting the error.
    "dev",
    "Application version",
);

// Choose the `Reqwest` backend, which supports asynchronous operations. If
// additional asynchronous backends are implemented in the future, you could
// select one of them by replacing reqwest() with the appropriate backend
// name.
let mut client = cb.reqwest().non_blocking().build().unwrap();
match client.send().await {
    Ok(response) => {
        // Looks good. Do stuff.
    },
    Err(error) => {
        // A bummer has happened. Handle it.
    },
}

   

Sessions API, synchronous client using the Ureq backend.

This example requires the

session-client, ureq, and sync features.

use lemon_bugsnag_rs::common::builder::client_builder::ClientBuilder;
use lemon_bugsnag_rs::common::traits::backend_builder_trait_sync::BackendBuilderTraitSync;
// Provides the `send()` function for synchronous backend clients.
use lemon_bugsnag_rs::common::traits::client_trait_sync::ClientTraitSync;

// To use the bundle rather than import each item separately:
// use lemon_bugsnag_rs::common::bundle::*;

// Start by retrieving a builder for BugSnag error-reporting API clients.
let mut cb = ClientBuilder::session();

cb.configure(
    "Your API key goes here",
    // A string to identify the source of the error report. For example,
    // "Company Name mobile app," "web API," or, "lemon-bugsnag-rs," depending
    // on how you want to track errors.
    "A name to identify your application",
    "Notifier version",
    // Release stage of application reporting the error.
    "dev",
    "Application version",
);

// Choose the `Ureq` backend.
let mut client = cb.ureq().build().unwrap();

let result = client.send();
if result.is_ok() {
    let response = result.unwrap();
    // Due to the way the Ureq clients are implemented, you will want to
    // check the HTTP response code to ensure you received the expected result.
    if response.status() != 200 {
        // Looks good. Do stuff.
    } else {
        // Possible 40x or 50x. Process as appropriate.
    }
} else {
    // A bummer has happened. Handle it.
}
Commit count: 0

cargo fmt