Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jasonroelofs/271206 to your computer and use it in GitHub Desktop.
Save jasonroelofs/271206 to your computer and use it in GitHub Desktop.
/* 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")
.define_constructor(Constructor<V8UnknownReturnValueException>());
// Throwing the exception:
throw Rice::Exception(rb_eUnknownReturnValueException, "Fly little bird!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment