#[non_exhaustive]
pub struct ErrorDetails { /* private fields */ }
Expand description

Groups the standard error messages structs. Provides associated functions and methods to setup and edit each error message independently. Used when extracting error details from tonic::Status, and when creating a tonic::Status with error details.

Implementations§

Generates an ErrorDetails struct with all fields set to None.

Examples
use tonic_types::{ErrorDetails};

let err_details = ErrorDetails::new();

Generates an ErrorDetails struct with BadRequest details and remaining fields set to None.

Examples
use tonic_types::{ErrorDetails, FieldViolation};

let err_details = ErrorDetails::with_bad_request(vec![
    FieldViolation::new("field_1", "description 1"),
    FieldViolation::new("field_2", "description 2"),
]);

Generates an ErrorDetails struct with BadRequest details (one FieldViolation set) and remaining fields set to None.

Examples
use tonic_types::{ErrorDetails};

let err_details = ErrorDetails::with_bad_request_violation(
    "field",
    "description",
);

Get BadRequest details, if any

Set BadRequest details. Can be chained with other .set_ and .add_ ErrorDetails methods.

Examples
use tonic_types::{ErrorDetails, FieldViolation};

let mut err_details = ErrorDetails::new();

err_details.set_bad_request(vec![
    FieldViolation::new("field_1", "description 1"),
    FieldViolation::new("field_2", "description 2"),
]);

Adds a FieldViolation to BadRequest details. Sets BadRequest details if it is not set yet. Can be chained with other .set_ and .add_ ErrorDetails methods.

Examples
use tonic_types::{ErrorDetails};

let mut err_details = ErrorDetails::new();

err_details.add_bad_request_violation("field", "description");

Returns true if BadRequest is set and its field_violations vector is not empty, otherwise returns false.

Examples
use tonic_types::{ErrorDetails};

let mut err_details = ErrorDetails::with_bad_request(vec![]);

assert_eq!(err_details.has_bad_request_violations(), false);

err_details.add_bad_request_violation("field", "description");

assert_eq!(err_details.has_bad_request_violations(), true);

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Converts to this type from a reference to the input type.
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Wrap the input message T in a tonic::Request
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more