Struct async_graphql::ServerError
source · [−]pub struct ServerError {
pub message: String,
pub source: Option<Arc<dyn Any + Send + Sync>>,
pub locations: Vec<Pos>,
pub path: Vec<PathSegment>,
pub extensions: Option<ErrorExtensionValues>,
}
Expand description
An error in a GraphQL server.
Fields
message: String
An explanatory message of the error.
source: Option<Arc<dyn Any + Send + Sync>>
The source of the error.
locations: Vec<Pos>
Where the error occurred.
path: Vec<PathSegment>
If the error occurred in a resolver, the path to the error.
extensions: Option<ErrorExtensionValues>
Extensions to the error.
Implementations
sourceimpl ServerError
impl ServerError
sourcepub fn new(message: impl Into<String>, pos: Option<Pos>) -> Self
pub fn new(message: impl Into<String>, pos: Option<Pos>) -> Self
Create a new server error with the message.
sourcepub fn source<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn source<T: Any + Send + Sync>(&self) -> Option<&T>
Get the source of the error.
Examples
use std::io::ErrorKind;
use async_graphql::*;
struct Query;
#[Object]
impl Query {
async fn value(&self) -> Result<i32> {
Err(Error::new_with_source(std::io::Error::new(
ErrorKind::Other,
"my error",
)))
}
}
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
let err = schema
.execute("{ value }")
.await
.into_result()
.unwrap_err()
.remove(0);
assert!(err.source::<std::io::Error>().is_some());
Trait Implementations
sourceimpl Clone for ServerError
impl Clone for ServerError
sourcefn clone(&self) -> ServerError
fn clone(&self) -> ServerError
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ServerError
impl Debug for ServerError
sourceimpl<'de> Deserialize<'de> for ServerError
impl<'de> Deserialize<'de> for ServerError
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
sourceimpl Display for ServerError
impl Display for ServerError
sourceimpl From<Error> for ServerError
impl From<Error> for ServerError
sourceimpl From<ServerError> for Vec<ServerError>
impl From<ServerError> for Vec<ServerError>
sourcefn from(single: ServerError) -> Self
fn from(single: ServerError) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<ServerError> for ServerError
impl PartialEq<ServerError> for ServerError
sourceimpl Serialize for ServerError
impl Serialize for ServerError
Auto Trait Implementations
impl !RefUnwindSafe for ServerError
impl Send for ServerError
impl Sync for ServerError
impl Unpin for ServerError
impl !UnwindSafe for ServerError
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> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
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
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