Sha256: 840923dfe96f931444abb91437f4ea7ce81a41de5ed166dbd34dc3e34944483e

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 KB

Contents

#include "Exception.hpp"
#include "protect.hpp"
#include "to_from_ruby.hpp"
#include "detail/ruby.hpp"

#ifdef HAVE_STDARG_PROTOTYPES
#include <stdarg.h>
#define va_init_list(a,b) va_start(a,b)
#else
#include <varargs.h>
#define va_init_list(a,b) va_start(a)
#endif

Rice::Exception::
Exception(VALUE e)
  : Exception_Base(e)
  , message_(Qnil)
  , message_guard_(&message_)
{
}

Rice::Exception::
Exception(Exception const & other)
  : Exception_Base(other)
  , message_(other.message_)
  , message_guard_(&message_)
{
}

Rice::Exception::
Exception(Object exc, char const * fmt, ...)
  : Exception_Base(Qnil)
  , message_(Qnil)
  , message_guard_(&message_)
{
  va_list args;
  char buf[BUFSIZ];
  
  va_init_list(args, fmt);
  vsnprintf(buf, BUFSIZ, fmt, args);
  buf[BUFSIZ - 1] = '\0';
  va_end(args);

  set_value(protect(rb_exc_new2, exc, buf));
}

Rice::String Rice::Exception::
message() const
{
  return protect(rb_funcall, value(), rb_intern("message"), 0);
}

char const * Rice::Exception::
what() const throw()
{
  message_ = message();
  return from_ruby<std::string>(message_).c_str();
}

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
rice2-2.2.1 rice/Exception.cpp
rice2-2.2.0 rice/Exception.cpp
rice-2.2.0 rice/Exception.cpp
rice-2.1.3 rice/Exception.cpp
rice-2.1.2 rice/Exception.cpp
rice-2.1.1 rice/Exception.cpp
rice-2.1.0 rice/Exception.cpp
rice-2.0.0 rice/Exception.cpp
rice-1.7.0 rice/Exception.cpp
rice-1.6.3 rice/Exception.cpp
rice-1.6.2 rice/Exception.cpp
rice-1.6.1 rice/Exception.cpp
rice-1.6.0 rice/Exception.cpp
rice-1.6.0.pre rice/Exception.cpp