Skip to main content

Report

Struct Report 

Source
pub struct Report { /* private fields */ }
Expand description

One error, panic or message, on its way to Flare.

Implementations§

Source§

impl Report

Source

pub fn new<C, M>( exception_class: C, message: M, location: &Location<'_>, ) -> Self
where C: Into<String>, M: Into<String>,

Creates a report with an exception class and a message.

location is the place where the report was made, like std::panic::Location::caller(). Without a stack trace, this place is the only frame of the report.

§Examples

Location::caller() returns the place that called the current function. Mark a helper function that creates reports with #[track_caller]. Then Location::caller() returns the place that called the helper, and not a place inside the helper:

use std::panic::Location;

use flareapp_core::Report;

#[track_caller]
fn payment_failed() -> Report {
    Report::new("my_app::PaymentFailed", "payment failed", Location::caller())
}

// The location of this report is this line, not the line in the helper.
let report = payment_failed();
Source

pub fn from_error<E: ReportableError + ?Sized>( error: &E, location: &Location<'_>, ) -> Self

Creates a report for an error. The exception class is the Rust type of the error, and the message is its Display output.

For a dyn Error, the exception class is the class that erased_exception_class returns. When that function finds no class, the class is Error.

Source

pub fn from_erased_error( error: &(dyn Error + 'static), location: &Location<'_>, ) -> Self

Creates a report for an error whose type is hidden, like the error in a Box<dyn Error>. The message is the Display output of the error.

The exception class is the class that erased_exception_class returns, so a std::io::Error gets its real type name. When that function finds no class, the class is Error.

Source

pub fn from_message<M: Into<String>>( message: M, level: Level, location: &Location<'_>, ) -> Self

Creates a report for a message, like a log line that needs attention.

Source

pub fn id(&self) -> ReportId

Returns the tracking id of the report.

Source

pub fn exception_class(&self) -> &str

Returns the exception class, like std::io::error::Error.

Source

pub fn set_exception_class<C: Into<String>>(&mut self, exception_class: C)

Changes the exception class, which Flare groups errors by.

Source

pub fn message(&self) -> &str

Returns the message.

Source

pub fn handled(&self) -> bool

Returns true when your code handled the error, and false for a panic.

Source

pub fn set_handled(&mut self, handled: bool)

Marks the error as handled by your code (true, the default) or not.

Source

pub fn set_context<K: Into<String>, V: Into<Value>>(&mut self, key: K, value: V)

Adds a piece of context to this report only.

Source

pub fn set_attribute<K: Into<String>, V: Into<Value>>( &mut self, key: K, value: V, )

Adds an attribute to this report only, like thread.name.

Source

pub fn set_location(&mut self, location: Frame)

Sets the place where the report was made, when it differs from the location given to Report::new. Without a stack trace, this place is the only frame.

Source

pub fn set_frames<R: ResolveFrames + 'static>(&mut self, frames: R)

Sets the stack trace. The worker thread resolves it before sending.

Trait Implementations§

Source§

impl Debug for Report

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Report

§

impl !Sync for Report

§

impl !UnwindSafe for Report

§

impl Forget for Report

§

impl Freeze for Report
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const dyn ResolveFrames is !null: Freeze, PhantomData<dyn ResolveFrames>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze, PhantomData<Glow>: Freeze, PhantomData<Breadcrumb>: Freeze,

§

impl Move for Report

§

impl Send for Report
where RawVecInner: Send, BoxRaw<dyn ResolveFrames>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send, &'static str: Send, String: Send,

§

impl Unpin for Report
where *const u8 is !null: Unpin, Box<dyn ResolveFrames>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, &'static str: Unpin, String: Unpin,

§

impl UnsafeUnpin for Report

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more