[][src]Struct glsp::GError

pub struct GError { /* fields omitted */ }

The error type generated by GameLisp code.

GResult<T> is an alias for Result<T, GError>.

The easiest way to generate an error yourself is by using one of the macros bail!, ensure! or error!.

The macro-no-op signal is represented by a special kind of GError which is not caught by try or try-verbose. This means that in order to trigger a macro_no_op!, the enclosing function must return GResult<T>.

The with_source method can be used to chain together two GErrors, or to chain an arbitrary Error type onto a GError.


impl GError[src]

pub fn new() -> GError[src]

pub fn from_str(st: &str) -> GError[src]

pub fn from_val<T>(t: T) -> GError where
    T: ToVal

pub fn macro_no_op() -> GError[src]

pub fn is_macro_no_op(&self) -> bool[src]

Returns true if this error was generated using macro_no_op! or GError::macro_no_op.

pub fn val(&self) -> Val[src]

Returns the error's payload. Panics if this error is a macro-no-op.

pub fn stack_trace(&self) -> Option<&str>[src]

Returns the error's saved stack trace.

Errors invoked in a dynamic context where verbose errors are disabled (for example, the dynamic scope of a try form) will not have a stack trace.

pub fn with_source(self, source_to_add: impl Error + 'static) -> GError[src]

Chains another error onto this GError.

This can be used to wrap arbitrary Error types in a GError.

let words = match fs::read_to_string("words.txt") {
	Ok(words) => words,
	Err(fs_err) => {
		return Err(error!("failed to open words.txt").with_source(fs_err))

Trait Implementations

impl Debug for GError[src]

impl Display for GError[src]

impl Error for GError[src]

Auto Trait Implementations

impl !GSend for GError

impl !GStore for GError

impl !RefUnwindSafe for GError

impl !Send for GError

impl !Sync for GError

impl Unpin for GError

impl !UnwindSafe for GError

Blanket Implementations

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

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

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

impl<T> Erased for T

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

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

impl<T> ToString for T where
    T: Display + ?Sized

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

type Error = Infallible

The type returned in the event of a conversion error.

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.