Struct juniper::FieldError [−][src]
pub struct FieldError { /* fields omitted */ }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 FieldError[src]
impl FieldErrorpub fn new<T: Display>(e: T, data: Value) -> FieldError[src]
pub fn new<T: Display>(e: T, data: Value) -> FieldErrorConstruct 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 data parameter will be added to the "data" field of the error
object in the JSON response:
{
"errors": [
"message": "Could not open connection to the database",
"locations": [{"line": 2, "column": 4}],
"data": {
"internal_error": "Connection refused"
}
]
}
If the argument is Value::null(), no extra data will be included.
Trait Implementations
impl Debug for FieldError[src]
impl Debug for FieldErrorfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for FieldError[src]
impl PartialEq for FieldErrorfn eq(&self, other: &FieldError) -> bool[src]
fn eq(&self, other: &FieldError) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &FieldError) -> bool[src]
fn ne(&self, other: &FieldError) -> boolThis method tests for !=.
impl<T: Display> From<T> for FieldError[src]
impl<T: Display> From<T> for FieldErrorfn from(e: T) -> FieldError[src]
fn from(e: T) -> FieldErrorPerforms the conversion.
Auto Trait Implementations
impl Send for FieldError
impl Send for FieldErrorimpl Sync for FieldError
impl Sync for FieldError