Struct warpgrapher::engine::resolvers::FieldError
source · [−]pub struct FieldError<S = DefaultScalarValue> { /* private fields */ }
Expand description
Error type for errors that occur during field resolution
Field errors are represented by a human-readable error message and an
optional Value
structure containing additional information.
They can be converted to from any type that implements std::fmt::Display
,
which makes error chaining with the ?
operator a breeze:
fn get_string(data: Vec<u8>) -> Result<String, FieldError>
{
let s = String::from_utf8(data)?;
Ok(s)
}
Implementations
sourceimpl<S> FieldError<S>
impl<S> FieldError<S>
sourcepub fn new<T>(e: T, extensions: Value<S>) -> FieldError<S> where
T: Display,
pub fn new<T>(e: T, extensions: Value<S>) -> FieldError<S> where
T: Display,
Construct a new error with additional data
You can use the graphql_value!
macro to construct an error:
use juniper::FieldError;
use juniper::graphql_value;
FieldError::new(
"Could not open connection to the database",
graphql_value!({ "internal_error": "Connection refused" })
);
The extensions
parameter will be added to the "extensions"
field of the error
object in the JSON response:
{
"errors": [
"message": "Could not open connection to the database",
"locations": [{"line": 2, "column": 4}],
"extensions": {
"internal_error": "Connection refused"
}
]
}
If the argument is Value::null()
, no extra data will be included.
sourcepub fn map_scalar_value<Into>(self) -> FieldError<Into> where
S: ScalarValue,
Into: ScalarValue,
pub fn map_scalar_value<Into>(self) -> FieldError<Into> where
S: ScalarValue,
Into: ScalarValue,
Maps the ScalarValue
type of this FieldError
into the specified one.
Trait Implementations
sourceimpl<S> Debug for FieldError<S> where
S: Debug,
impl<S> Debug for FieldError<S> where
S: Debug,
sourceimpl<T, S> From<T> for FieldError<S> where
T: Display,
S: ScalarValue,
impl<T, S> From<T> for FieldError<S> where
T: Display,
S: ScalarValue,
sourcefn from(e: T) -> FieldError<S>
fn from(e: T) -> FieldError<S>
Converts to this type from the input type.
sourceimpl<S> PartialEq<FieldError<S>> for FieldError<S> where
S: PartialEq<S>,
impl<S> PartialEq<FieldError<S>> for FieldError<S> where
S: PartialEq<S>,
sourcefn eq(&self, other: &FieldError<S>) -> bool
fn eq(&self, other: &FieldError<S>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FieldError<S>) -> bool
fn ne(&self, other: &FieldError<S>) -> bool
This method tests for !=
.
impl<S1, S2> IntoFieldError<S2> for FieldError<S1> where
S1: ScalarValue,
S2: ScalarValue,
impl<S> StructuralPartialEq for FieldError<S>
Auto Trait Implementations
impl<S> RefUnwindSafe for FieldError<S> where
S: RefUnwindSafe,
impl<S> Send for FieldError<S> where
S: Send,
impl<S> Sync for FieldError<S> where
S: Sync,
impl<S> Unpin for FieldError<S> where
S: Unpin,
impl<S> UnwindSafe for FieldError<S> where
S: UnwindSafe,
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>
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