Struct juniper::executor::FieldError[][src]

pub struct FieldError<S = DefaultScalarValue> { /* fields omitted */ }
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

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;
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.

pub fn map_scalar_value<Into>(self) -> FieldError<Into> where
    S: ScalarValue,
    Into: ScalarValue
[src]

Maps the ScalarValue type of this FieldError into the specified one.

Trait Implementations

impl<S: Debug> Debug for FieldError<S>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T: Display, S> From<T> for FieldError<S> where
    S: ScalarValue
[src]

fn from(e: T) -> FieldError<S>[src]

Performs the conversion.

impl<S1: ScalarValue, S2: ScalarValue> IntoFieldError<S2> for FieldError<S1>[src]

impl<S: PartialEq> PartialEq<FieldError<S>> for FieldError<S>[src]

fn eq(&self, other: &FieldError<S>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &FieldError<S>) -> bool[src]

This method tests for !=.

impl<S> StructuralPartialEq for FieldError<S>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<!> for T[src]

pub fn from(t: !) -> T[src]

Performs the conversion.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V