pub struct CliReport<'s> { /* private fields */ }
Expand description

A diagnostic report that can be printed to a CLI with pretty colors and labeled lines of GraphQL source code.

Custom errors can use this in their Display or Debug implementations to build a report and then write it out with fmt.

Implementations§

source§

impl<'s> CliReport<'s>

source

pub fn builder( sources: &'s SourceMap, main_location: Option<NodeLocation>, color: Color ) -> Self

Returns a builder for creating diagnostic reports.

Provide GraphQL source files and the main location for the diagnostic. Source files can be obtained from Schema::sources or ExecutableDocument::sources.

source

pub fn with_message(&mut self, message: impl ToString)

Set the main message for the report.

source

pub fn with_help(&mut self, help: impl ToString)

Set the help message for the report, usually a suggestion on how to fix the error.

source

pub fn with_note(&mut self, note: impl ToString)

Set a note for the report, providing additional information that isn’t related to a source location (when a label should be used).

source

pub fn with_label_opt( &mut self, location: Option<NodeLocation>, message: impl ToString )

Add a label at a given location. If the location is None, the message is discarded.

source

pub fn write(self, w: impl Write) -> Result<()>

Write the report to a Write.

source

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

Write the report to a fmt::Formatter.

source

pub fn into_string(self) -> String

Write the report to a new String

Auto Trait Implementations§

§

impl<'s> Freeze for CliReport<'s>

§

impl<'s> RefUnwindSafe for CliReport<'s>

§

impl<'s> Send for CliReport<'s>

§

impl<'s> Sync for CliReport<'s>

§

impl<'s> Unpin for CliReport<'s>

§

impl<'s> UnwindSafe for CliReport<'s>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.