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 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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