Created
January 7, 2010 03:41
-
-
Save dominiek/270959 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Basically, I want to throw a custom exception from C++. I'm kind of lost on how to do that :/ */ | |
// exceptions.hpp | |
class V8UnknownReturnValueException : public Rice::Exception { | |
}; | |
Rice::Object rb_eUnknownReturnValueException; | |
// Initializing the guy (rb_mV8 is a defined module) | |
rb_eUnknownReturnValueException = rb_mV8.define_class<V8UnknownReturnValueException>("UnknownReturnValueException"); | |
// Throwing the exception: | |
throw Rice::Exception(rb_eUnknownReturnValueException, "Fly little bird!"); | |
/* When running it: | |
ruby examples/hello.rb | |
examples/hello.rb:13:in `new': allocator undefined for V8::UnknownReturnValueException (TypeError) | |
from examples/hello.rb:13:in `run' | |
from examples/hello.rb:13 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment