Struct graphql_client::Error
source · [−]pub struct Error {
pub message: String,
pub locations: Option<Vec<Location>>,
pub path: Option<Vec<PathFragment>>,
pub extensions: Option<HashMap<String, Value>>,
}
Expand description
An element in the top-level errors
array of a response body.
This tries to be as close to the spec as possible.
use graphql_client::*;
let body: Response<ResponseData> = serde_json::from_value(json!({
"data": null,
"errors": [
{
"message": "The server crashed. Sorry.",
"locations": [{ "line": 1, "column": 1 }]
},
{
"message": "Seismic activity detected",
"path": ["underground", 20]
},
],
}))?;
let expected: Response<ResponseData> = Response {
data: None,
errors: Some(vec![
Error {
message: "The server crashed. Sorry.".to_owned(),
locations: Some(vec![
Location {
line: 1,
column: 1,
}
]),
path: None,
extensions: None,
},
Error {
message: "Seismic activity detected".to_owned(),
locations: None,
path: Some(vec![
PathFragment::Key("underground".into()),
PathFragment::Index(20),
]),
extensions: None,
},
]),
extensions: None,
};
assert_eq!(body, expected);
Fields
message: String
The human-readable error message. This is the only required field.
locations: Option<Vec<Location>>
Which locations in the query the error applies to.
path: Option<Vec<PathFragment>>
Which path in the query the error applies to, e.g. ["users", 0, "email"]
.
extensions: Option<HashMap<String, Value>>
Additional errors. Their exact format is defined by the server.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Error
impl<'de> Deserialize<'de> for Error
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Error
Auto Trait Implementations
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more