Function magnus::define_error

source ·
pub fn define_error(
    name: &str,
    superclass: ExceptionClass
) -> Result<ExceptionClass, Error>
Expand description

Define an exception class in the root scope.

§Panics

Panics if called from a non-Ruby thread. See Ruby::define_error for the non-panicking version.

§Examples

use magnus::{define_error, exception, rb_assert};

define_error("ExampleError", exception::standard_error()).unwrap();
rb_assert!("ExampleError.is_a?(Class)");
rb_assert!("ExampleError < Exception");