[][src]Trait rosy::Exception

pub unsafe trait Exception: Object + Error {
    fn into_any_exception(self) -> AnyException { ... }
fn as_any_exception(&self) -> &AnyException { ... }
unsafe fn raise(self) -> ! { ... }
fn backtrace(&self) -> Option<Array<String>> { ... }
fn cause(&self) -> Option<AnyException> { ... } }

Some concrete Ruby exception.

Safety

The implementing object type must be an exception type. Otherwise, methods like backtrace and cause will cause a segmentation fault.

Provided methods

fn into_any_exception(self) -> AnyException

Returns self as an AnyException.

fn as_any_exception(&self) -> &AnyException

Returns a reference to self as an AnyObject.

unsafe fn raise(self) -> !

Raises the exception.

Safety

This call should be wrapped around in code that can properly handle self; otherwise a segmentation fault will occur.

Examples

Using protected ensures that calling this method is indeed safe:

use rosy::{AnyException, Exception, protected};

let exc = AnyException::new("Oh noes, something happened!");
let err = protected(|| unsafe { exc.raise() }).unwrap_err();

assert_eq!(exc, err);

fn backtrace(&self) -> Option<Array<String>>

Returns a backtrace associated with self.

fn cause(&self) -> Option<AnyException>

The underlying exception that caused self.

Loading content...

Implementors

Loading content...