Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ruby_exceptions.hpp File Reference

Helper macros and classes for converting C++ exceptions to Ruby exceptions. More...

#include <ruby.h>
#include <stdexcept>
#include "detail/ruby_hacks.hpp"
#include "ruby_exceptions.ipp"

Include dependency graph for ruby_exceptions.hpp:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  Exc_Ruby

Defines

#define RUBY_TRY
 Start a block to catch Ruby exceptions and rethrow them.

#define RUBY_RETHROW(ex)
 Given a Ruby exception as a VALUE, safely raise the exception as a Ruby exception. This should be used inside a RUBY_TRY/RUBY_CATCH block.

#define RUBY_CATCH
 End a RUBY_TRY block.


Detailed Description

Helper macros and classes for converting C++ exceptions to Ruby exceptions.


Define Documentation

#define RUBY_CATCH
 

Value:

catch(::Exc_Ruby::Ruby_Exception const & ex) \
  { \
    RUBY_RETHROW(ex.ex); \
  } \
  catch(::Exc_Ruby::Ruby_Jump_Tag const & ex) \
  { \
    Exc_Ruby__ruby_jump_tag = ex.tag; \
    goto Exc_Ruby__ruby_jump_tag; \
  } \
  catch(std::bad_alloc const & ex) \
  { \
    /* This won't work quite right if the rb_exc_new2 fails; not    */ \
    /* much we can do about that, since Ruby doesn't give us access */ \
    /* to a pre-allocated NoMemoryError object                      */ \
    RUBY_RETHROW(rb_exc_new2(rb_eNoMemError, ex.what())); \
  } \
  catch(std::exception const & ex) \
  { \
    /* This can raise a NoMemoryError in VERY rare circumstances    */ \
    RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, ex.what())); \
  } \
  catch(...) \
  { \
    RUBY_RETHROW(rb_exc_new2(rb_eRuntimeError, "unknown C++ exception thrown")); \
  } \
End a RUBY_TRY block.

#define RUBY_RETHROW ex   ) 
 

Value:

Exc_Ruby__ruby_exc = ex; \
  goto Exc_Ruby__ruby_exception;
Given a Ruby exception as a VALUE, safely raise the exception as a Ruby exception. This should be used inside a RUBY_TRY/RUBY_CATCH block.

#define RUBY_TRY
 

Value:

VALUE Exc_Ruby__ruby_exc = Qnil; \
  int Exc_Ruby__ruby_jump_tag = 0; \
  \
  goto start_of_RUBY_TRY; \
  \
  Exc_Ruby__ruby_exception: \
    rb_exc_raise(Exc_Ruby__ruby_exc); \
  Exc_Ruby__ruby_jump_tag: \
    rb_jump_tag(Exc_Ruby__ruby_jump_tag); \
  \
  start_of_RUBY_TRY: \
  try
Start a block to catch Ruby exceptions and rethrow them.


Generated on Sat Jan 1 12:02:23 2005 for Exceptional Ruby by doxygen 1.3.6