[−][src]Struct juniper::FieldError
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) }
Methods
impl<S> FieldError<S>[src]
pub fn new<T: Display>(e: T, extensions: Value<S>) -> FieldError<S>[src]
Construct a new error with additional data
You can use the graphql_value! macro to construct an error:
use juniper::FieldError; 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.
Trait Implementations
impl<S> IntoFieldError<S> for FieldError<S>[src]
fn into_field_error(self) -> FieldError<S>[src]
impl<S: PartialEq> PartialEq<FieldError<S>> for FieldError<S>[src]
fn eq(&self, other: &FieldError<S>) -> bool[src]
fn ne(&self, other: &FieldError<S>) -> bool[src]
impl<T: Display, S> From<T> for FieldError<S> where
S: ScalarValue, [src]
S: ScalarValue,
fn from(e: T) -> FieldError<S>[src]
impl<S: Debug> Debug for FieldError<S>[src]
Auto Trait Implementations
impl<S> Send for FieldError<S> where
S: Send,
S: Send,
impl<S> Sync for FieldError<S> where
S: Sync,
S: Sync,
Blanket Implementations
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>, [src]
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,