Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Exception handlings

Data Structures

struct  bug_reporters
 
struct  path_string
 
struct  report_expansion
 
struct  name_error_message_struct
 

Macros

#define EXIT_SUCCESS   0
 
#define WIFEXITED(status)   1
 
#define WEXITSTATUS(status)   (status)
 
#define with_warn_vsprintf(enc, file, line, fmt)
 
#define with_warning_string(mesg, enc, fmt)    with_warning_string_from(mesg, enc, fmt, fmt)
 
#define with_warning_string_from(mesg, enc, fmt, last_arg)
 
#define MAX_BUG_REPORTERS   0x100
 
#define REPORT_BUG_BUFSIZ   256
 
#define bug_report_begin(out, fmt)
 
#define report_bug(file, line, fmt, ctx)
 
#define report_bug_valist(file, line, fmt, ctx, args)
 
#define write_or_abort(fd, str, len)   (write((fd), (str), (len)) < 0 ? abort() : (void)0)
 
#define WRITE_CONST(fd, str)   write_or_abort((fd),(str),sizeof(str) - 1)
 
#define UNDEF_LEAKED   "undef leaked to the Ruby space"
 
#define id_cause   ruby_static_id_cause
 
#define id_bt   idBt
 
#define id_bt_locations   idBt_locations
 
#define id_mesg   idMesg
 
#define id_name   idName
 
#define frozen_err_receiver   name_err_receiver
 
#define ruby_verbose   (*rb_ruby_verbose_ptr())
 This variable controls whether the interpreter is in debug mode. More...
 
#define ruby_debug   (*rb_ruby_debug_ptr())
 This variable controls whether the interpreter is in debug mode. More...
 

Typedefs

typedef struct name_error_message_struct name_error_message_t
 

Enumerations

enum  rb_warning_category_t {
  RB_WARN_CATEGORY_NONE , RB_WARN_CATEGORY_DEPRECATED , RB_WARN_CATEGORY_EXPERIMENTAL , RB_WARN_CATEGORY_PERFORMANCE ,
  RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK , RB_WARN_CATEGORY_DEFAULT_BITS , RB_WARN_CATEGORY_ALL_BITS
}
 Warning categories. More...
 
enum  rb_io_wait_readwrite { RB_IO_WAIT_READABLE , RB_IO_WAIT_WRITABLE }
 for rb_readwrite_sys_fail first argument More...
 

Functions

VALUE rb_iseqw_local_variables (VALUE iseqval)
 
VALUE rb_iseqw_new (const rb_iseq_t *)
 
int rb_str_end_with_asciichar (VALUE str, int c)
 
static const char * rb_strerrno (int err)
 
static int err_position_0 (char *buf, long len, const char *file, int line)
 
static VALUE err_vcatf (VALUE str, const char *pre, const char *file, int line, const char *fmt, va_list args)
 
static VALUE syntax_error_with_path (VALUE, VALUE, VALUE *, rb_encoding *)
 
VALUE rb_syntax_error_append (VALUE exc, VALUE file, int line, int column, rb_encoding *enc, const char *fmt, va_list args)
 
static unsigned int rb_warning_category_mask (VALUE category)
 
rb_warning_category_t rb_warning_category_from_name (VALUE category)
 
static VALUE rb_warning_category_to_name (rb_warning_category_t category)
 
void rb_warning_category_update (unsigned int mask, unsigned int bits)
 
bool rb_warning_category_enabled_p (rb_warning_category_t category)
 
static VALUE rb_warning_s_aref (VALUE mod, VALUE category)
 
static VALUE rb_warning_s_aset (VALUE mod, VALUE category, VALUE flag)
 
static VALUE rb_warning_s_categories (VALUE mod)
 
static VALUE rb_warning_s_warn (int argc, VALUE *argv, VALUE mod)
 
static VALUE rb_warning_warn (VALUE mod, VALUE str)
 
static int rb_warning_warn_arity (void)
 
static VALUE rb_warn_category (VALUE str, VALUE category)
 
static void rb_write_warning_str (VALUE str)
 
static VALUE warn_vsprintf (rb_encoding *enc, const char *file, int line, const char *fmt, va_list args)
 
void rb_compile_warn (const char *file, int line, const char *fmt,...)
 Identical to rb_compile_warning(), except it reports unless $VERBOSE is nil. More...
 
void rb_enc_compile_warn (rb_encoding *enc, const char *file, int line, const char *fmt,...)
 
void rb_compile_warning (const char *file, int line, const char *fmt,...)
 Issues a compile-time warning that happens at __file__:__line__. More...
 
void rb_enc_compile_warning (rb_encoding *enc, const char *file, int line, const char *fmt,...)
 
void rb_category_compile_warn (rb_warning_category_t cat, const char *file, int line, const char *fmt,...)
 Identical to rb_compile_warn(), except it also accepts category. More...
 
static VALUE warning_string (rb_encoding *enc, const char *fmt, va_list args)
 
void rb_warn (const char *fmt,...)
 Identical to rb_warning(), except it reports unless $VERBOSE is nil. More...
 
void rb_category_warn (rb_warning_category_t cat, const char *fmt,...)
 Identical to rb_category_warning(), except it reports unless $VERBOSE is nil. More...
 
void rb_enc_warn (rb_encoding *enc, const char *fmt,...)
 
void rb_warning (const char *fmt,...)
 Issues a warning. More...
 
void rb_category_warning (rb_warning_category_t cat, const char *fmt,...)
 Identical to rb_warning(), except it takes additional "category" parameter. More...
 
VALUE rb_warning_string (const char *fmt,...)
 
static bool deprecation_warning_enabled (void)
 
static void warn_deprecated (VALUE mesg, const char *removal, const char *suggest)
 
void rb_warn_deprecated (const char *fmt, const char *suggest,...)
 
void rb_warn_deprecated_to_remove (const char *removal, const char *fmt, const char *suggest,...)
 
static int end_with_asciichar (VALUE str, int c)
 
static VALUE warning_write (int argc, VALUE *argv, VALUE buf)
 
VALUE rb_ec_backtrace_location_ary (const rb_execution_context_t *ec, long lev, long n, bool skip_internal)
 
static VALUE rb_warn_m (rb_execution_context_t *ec, VALUE exc, VALUE msgs, VALUE uplevel, VALUE category)
 
int rb_bug_reporter_add (void(*func)(FILE *, void *), void *data)
 
static bool path_sep_p (char x)
 
static char * append_pathname (char *p, const char *pe, VALUE str)
 
static char * append_basename (char *p, const char *pe, struct path_string *path, VALUE str)
 
static void finish_report (FILE *out, rb_pid_t pid)
 
static char * expand_report_argument (const char **input_template, struct report_expansion *values, char *buf, size_t size, bool word)
 
FILEruby_popen_writer (char *const *argv, rb_pid_t *pid)
 
static FILEopen_report_path (const char *template, char *buf, size_t size, rb_pid_t *pid)
 
static FILEbug_report_file (const char *file, int line, rb_pid_t *pid)
 
 FUNC_MINIMIZED (static void bug_important_message(FILE *out, const char *const msg, size_t len))
 
static void bug_important_message (FILE *out, const char *const msg, size_t len)
 
static void preface_dump (FILE *out)
 
static void postscript_dump (FILE *out)
 
static void bug_report_begin_valist (FILE *out, const char *fmt, va_list args)
 
static void bug_report_end (FILE *out, rb_pid_t pid)
 
void ruby_set_crash_report (const char *template)
 
static void die (void)
 
static void rb_bug_without_die (const char *fmt, va_list args)
 
void rb_bug (const char *fmt,...)
 Interpreter panic switch. More...
 
void rb_bug_for_fatal_signal (ruby_sighandler_t default_sighandler, int sig, const void *ctx, const char *fmt,...)
 
void rb_bug_errno (const char *msg, int err)
 This is a wrapper of rb_bug() which automatically constructs appropriate message from the passed errno. More...
 
void rb_async_bug_errno (const char *mesg, int errno_arg)
 
void rb_report_bug_valist (VALUE file, int line, const char *fmt, va_list args)
 
void rb_assert_failure (const char *file, int line, const char *name, const char *expr)
 
void rb_assert_failure_detail (const char *file, int line, const char *name, const char *expr, const char *fmt,...)
 
const char * rb_builtin_type_name (int t)
 
static VALUE displaying_class_of (VALUE x)
 
static const char * builtin_class_name (VALUE x)
 
const char * rb_builtin_class_name (VALUE x)
 
static void unexpected_type (VALUE, int, int)
 
void rb_check_type (VALUE x, int t)
 This was the old implementation of Check_Type(), but they diverged. More...
 
void rb_unexpected_type (VALUE self, int t)
 Fails with the given object's type incompatibility to the type. More...
 
int rb_typeddata_inherited_p (const rb_data_type_t *child, const rb_data_type_t *parent)
 Checks for the domestic relationship between the two. More...
 
int rb_typeddata_is_kind_of (VALUE obj, const rb_data_type_t *data_type)
 Checks if the given object is of given kind. More...
 
int rb_typeddata_is_instance_of (VALUE obj, const rb_data_type_t *data_type)
 
void * rb_check_typeddata (VALUE obj, const rb_data_type_t *data_type)
 Identical to rb_typeddata_is_kind_of(), except it raises exceptions instead of returning false. More...
 
VALUE rb_exc_new (VALUE etype, const char *ptr, long len)
 Creates an instance of the passed exception class. More...
 
VALUE rb_exc_new_cstr (VALUE etype, const char *s)
 Identical to rb_exc_new(), except it assumes the passed pointer is a pointer to a C string. More...
 
VALUE rb_exc_new_str (VALUE etype, VALUE str)
 Identical to rb_exc_new_cstr(), except it takes a Ruby's string instead of C's. More...
 
static VALUE exc_init (VALUE exc, VALUE mesg)
 
static VALUE exc_initialize (int argc, VALUE *argv, VALUE exc)
 
static VALUE exc_exception (int argc, VALUE *argv, VALUE self)
 
static VALUE exc_to_s (VALUE exc)
 
void rb_error_write (VALUE errinfo, VALUE emesg, VALUE errat, VALUE str, VALUE opt, VALUE highlight, VALUE reverse)
 
VALUE rb_get_message (VALUE exc)
 
VALUE rb_get_detailed_message (VALUE exc, VALUE opt)
 
static VALUE exc_s_to_tty_p (VALUE self)
 
static VALUE check_highlight_keyword (VALUE opt, int auto_tty_detect)
 
static VALUE check_order_keyword (VALUE opt)
 
static VALUE exc_full_message (int argc, VALUE *argv, VALUE exc)
 
static VALUE exc_message (VALUE exc)
 
static VALUE exc_detailed_message (int argc, VALUE *argv, VALUE exc)
 
static VALUE exc_inspect (VALUE exc)
 
static VALUE exc_backtrace (VALUE exc)
 
static VALUE rb_check_backtrace (VALUE)
 
VALUE rb_get_backtrace (VALUE exc)
 
static VALUE exc_backtrace_locations (VALUE exc)
 
static VALUE exc_set_backtrace (VALUE exc, VALUE bt)
 
VALUE rb_exc_set_backtrace (VALUE exc, VALUE bt)
 
static VALUE exc_cause (VALUE exc)
 
static VALUE try_convert_to_exception (VALUE obj)
 
static VALUE exc_equal (VALUE exc, VALUE obj)
 
static VALUE exit_initialize (int argc, VALUE *argv, VALUE exc)
 
static VALUE exit_status (VALUE exc)
 
static VALUE exit_success_p (VALUE exc)
 
static VALUE err_init_recv (VALUE exc, VALUE recv)
 
static VALUE frozen_err_initialize (int argc, VALUE *argv, VALUE self)
 
void rb_name_error (ID id, const char *fmt,...)
 Raises an instance of rb_eNameError. More...
 
void rb_name_error_str (VALUE str, const char *fmt,...)
 Identical to rb_name_error(), except it takes a VALUE instead of ID. More...
 
static VALUE name_err_init_attr (VALUE exc, VALUE recv, VALUE method)
 
static VALUE name_err_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE rb_name_err_mesg_new (VALUE mesg, VALUE recv, VALUE method)
 
static VALUE name_err_init (VALUE exc, VALUE mesg, VALUE recv, VALUE method)
 
VALUE rb_name_err_new (VALUE mesg, VALUE recv, VALUE method)
 
static VALUE name_err_name (VALUE self)
 
static VALUE name_err_local_variables (VALUE self)
 
static VALUE nometh_err_init_attr (VALUE exc, VALUE args, int priv)
 
static VALUE nometh_err_initialize (int argc, VALUE *argv, VALUE self)
 
VALUE rb_nomethod_err_new (VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv)
 
static void name_err_mesg_mark (void *p)
 
static void name_err_mesg_update (void *p)
 
static VALUE rb_name_err_mesg_init (VALUE klass, VALUE mesg, VALUE recv, VALUE name)
 
static VALUE name_err_mesg_alloc (VALUE klass)
 
static VALUE name_err_mesg_init_copy (VALUE obj1, VALUE obj2)
 
static VALUE name_err_mesg_equal (VALUE obj1, VALUE obj2)
 
static VALUE name_err_mesg_receiver_name (VALUE obj)
 
static VALUE name_err_mesg_to_str (VALUE obj)
 
static VALUE name_err_mesg_dump (VALUE obj, VALUE limit)
 
static VALUE name_err_mesg_load (VALUE klass, VALUE str)
 
static VALUE name_err_receiver (VALUE self)
 
static VALUE nometh_err_args (VALUE self)
 
static VALUE nometh_err_private_call_p (VALUE self)
 
void rb_invalid_str (const char *str, const char *type)
 Honestly I don't understand the name, but it raises an instance of rb_eArgError. More...
 
static VALUE key_err_receiver (VALUE self)
 
static VALUE key_err_key (VALUE self)
 
VALUE rb_key_err_new (VALUE mesg, VALUE recv, VALUE key)
 
static VALUE key_err_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE no_matching_pattern_key_err_matchee (VALUE self)
 
static VALUE no_matching_pattern_key_err_key (VALUE self)
 
static VALUE no_matching_pattern_key_err_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE syntax_error_initialize (int argc, VALUE *argv, VALUE self)
 
void rb_free_warning (void)
 
static VALUE setup_syserr (int n, const char *name)
 
static VALUE set_syserr (int n, const char *name)
 
static VALUE get_syserr (int n)
 
static VALUE syserr_initialize (int argc, VALUE *argv, VALUE self)
 
static VALUE syserr_errno (VALUE self)
 
static VALUE syserr_eqq (VALUE self, VALUE exc)
 
static VALUE exception_alloc (VALUE klass)
 
static VALUE exception_dumper (VALUE exc)
 
static int ivar_copy_i (ID key, VALUE val, st_data_t exc)
 
void rb_exc_check_circular_cause (VALUE exc)
 
static VALUE exception_loader (VALUE exc, VALUE obj)
 
void Init_Exception (void)
 
void rb_enc_raise (rb_encoding *enc, VALUE exc, const char *fmt,...)
 Identical to rb_raise(), except it additionally takes an encoding. More...
 
void rb_vraise (VALUE exc, const char *fmt, va_list ap)
 
void rb_raise (VALUE exc, const char *fmt,...)
 Exception entry point. More...
 
static void raise_loaderror (VALUE path, VALUE mesg)
 
void rb_loaderror (const char *fmt,...)
 Raises an instance of rb_eLoadError. More...
 
void rb_loaderror_with_path (VALUE path, const char *fmt,...)
 Identical to rb_loaderror(), except it additionally takes which file is unable to load. More...
 
void rb_notimplement (void)
 
void rb_fatal (const char *fmt,...)
 Raises the unsung "fatal" exception. More...
 
static VALUE make_errno_exc (const char *mesg)
 
static VALUE make_errno_exc_str (VALUE mesg)
 
VALUE rb_syserr_new (int err, const char *msg)
 Creates an exception object that represents the given C errno. More...
 
VALUE rb_syserr_new_str (int n, VALUE arg)
 Identical to rb_syserr_new(), except it takes the message in Ruby's String instead of C's. More...
 
void rb_syserr_fail (int err, const char *msg)
 Raises appropriate exception that represents a C errno. More...
 
void rb_syserr_fail_str (int err, VALUE msg)
 Identical to rb_syserr_fail(), except it takes the message in Ruby's String instead of C's. More...
 
void rb_sys_fail (const char *msg)
 Converts a C errno into a Ruby exception, then raises it. More...
 
void rb_sys_fail_str (VALUE msg)
 Identical to rb_sys_fail(), except it takes the message in Ruby's String instead of C's. More...
 
static void rb_mod_exc_raise (VALUE exc, VALUE mod)
 
void rb_mod_sys_fail (VALUE mod, const char *msg)
 Identical to rb_sys_fail(), except it takes additional module to extend the exception object before raising. More...
 
void rb_mod_sys_fail_str (VALUE mod, VALUE msg)
 Identical to rb_mod_sys_fail(), except it takes the message in Ruby's String instead of C's. More...
 
void rb_mod_syserr_fail (VALUE mod, int err, const char *msg)
 Identical to rb_mod_sys_fail(), except it does not depend on C global variable errno. More...
 
void rb_mod_syserr_fail_str (VALUE mod, int err, VALUE msg)
 Identical to rb_mod_syserr_fail(), except it takes the message in Ruby's String instead of C's. More...
 
static void syserr_warning (VALUE mesg, int err)
 
void rb_sys_warning (const char *fmt,...)
 Identical to rb_sys_fail(), except it does not raise an exception to render a warning instead. More...
 
void rb_sys_enc_warning (rb_encoding *enc, const char *fmt,...)
 
void rb_syserr_enc_warning (int err, rb_encoding *enc, const char *fmt,...)
 
void rb_load_fail (VALUE path, const char *err)
 
void rb_error_frozen (const char *what)
 Identical to rb_frozen_error_raise(), except its raising exception has a message like "can't modify frozen /what/". More...
 
void rb_frozen_error_raise (VALUE frozen_obj, const char *fmt,...)
 Raises an instance of rb_eFrozenError. More...
 
static VALUE inspect_frozen_obj (VALUE obj, VALUE mesg, int recur)
 
static VALUE get_created_info (VALUE obj, int *pline)
 
void rb_error_frozen_object (VALUE frozen_obj)
 Identical to rb_error_frozen(), except it takes arbitrary Ruby object instead of C's string. More...
 
void rb_warn_unchilled_literal (VALUE obj)
 
void rb_warn_unchilled_symbol_to_s (VALUE obj)
 
void rb_check_frozen (VALUE obj)
 Queries if the passed object is frozen. More...
 
void rb_check_copyable (VALUE obj, VALUE orig)
 Ensures that the passed object can be initialize_copy relationship. More...
 
void Init_syserr (void)
 
void rb_exc_raise (VALUE mesg)
 Raises an exception in the current thread. More...
 
void rb_exc_fatal (VALUE mesg)
 Raises a fatal error in the current thread. More...
 
VALUE rb_errinfo (void)
 This is the same as $! in Ruby. More...
 
void rb_set_errinfo (VALUE err)
 Sets the current exception ($!) to the given value. More...
 
void rb_readwrite_sys_fail (enum rb_io_wait_readwrite waiting, const char *msg)
 Raises appropriate exception using the parameters. More...
 
void rb_iter_break (void)
 Breaks from a block. More...
 
void rb_iter_break_value (VALUE val)
 Identical to rb_iter_break(), except it additionally takes the "value" of this breakage. More...
 
void rb_exit (int status)
 Terminates the current execution context. More...
 
void rb_readwrite_syserr_fail (enum rb_io_wait_readwrite waiting, int err, const char *msg)
 Identical to rb_readwrite_sys_fail(), except it does not depend on C global variable errno. More...
 
VALUE rb_rescue (VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2)
 Identical to rb_rescue2(), except it does not take a list of exception classes. More...
 
VALUE rb_rescue2 (VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
 An equivalent of rescue clause. More...
 
VALUE rb_vrescue2 (VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2, va_list ap)
 Identical to rb_rescue2(), except it takes va_list instead of variadic number of arguments. More...
 
VALUE rb_ensure (VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*e_proc)(VALUE), VALUE data2)
 An equivalent to ensure clause. More...
 

Variables

long rb_backtrace_length_limit = -1
 
VALUE rb_eEAGAIN
 
VALUE rb_eEWOULDBLOCK
 
VALUE rb_eEINPROGRESS
 
static VALUE rb_mWarning
 
static VALUE rb_cWarningBuffer
 
static ID id_warn
 
static ID id_category
 
static ID id_deprecated
 
static ID id_experimental
 
static ID id_performance
 
static ID id_strict_unused_block
 
static VALUE sym_category
 
static VALUE sym_highlight
 
struct {
   st_table *   id2enum
 
   st_table *   enum2id
 
warning_categories
 
const char * rb_dynamic_description
 
static unsigned int warning_disabled_categories
 
static struct bug_reporters bug_reporters [MAX_BUG_REPORTERS]
 
static int bug_reporters_size
 
static const char PATHSEP_REPLACE = '!'
 
static const char * crash_report
 
static const char builtin_types [][10]
 
VALUE rb_eException
 Mother of all exceptions. More...
 
VALUE rb_eSystemExit
 SystemExit exception. More...
 
VALUE rb_eInterrupt
 Interrupt exception. More...
 
VALUE rb_eSignal
 SignalException exception. More...
 
VALUE rb_eFatal
 fatal exception. More...
 
VALUE rb_eStandardError
 StandardError exception. More...
 
VALUE rb_eRuntimeError
 RuntimeError exception. More...
 
VALUE rb_eFrozenError
 FrozenError exception. More...
 
VALUE rb_eTypeError
 TypeError exception. More...
 
VALUE rb_eArgError
 ArgumentError exception. More...
 
VALUE rb_eIndexError
 IndexError exception. More...
 
VALUE rb_eKeyError
 KeyError exception. More...
 
VALUE rb_eRangeError
 RangeError exception. More...
 
VALUE rb_eNameError
 NameError exception. More...
 
VALUE rb_eEncodingError
 EncodingError exception. More...
 
VALUE rb_eEncCompatError
 Encoding::CompatibilityError exception. More...
 
VALUE rb_eNoMethodError
 NoMethodError exception. More...
 
VALUE rb_eSecurityError
 SecurityError exception. More...
 
VALUE rb_eNotImpError
 NotImplementedError exception. More...
 
VALUE rb_eNoMemError
 NoMemoryError exception. More...
 
VALUE rb_cNameErrorMesg
 NameError::Message class. More...
 
VALUE rb_eNoMatchingPatternError
 NoMatchingPatternError exception. More...
 
VALUE rb_eNoMatchingPatternKeyError
 NoMatchingPatternKeyError exception. More...
 
VALUE rb_eScriptError
 ScriptError exception. More...
 
VALUE rb_eSyntaxError
 SyntaxError exception. More...
 
VALUE rb_eLoadError
 LoadError exception. More...
 
VALUE rb_eSystemCallError
 SystemCallError exception. More...
 
VALUE rb_mErrno
 Errno module. More...
 
static VALUE rb_eNOERROR
 
ID ruby_static_id_cause
 
static ID id_message
 
static ID id_detailed_message
 
static ID id_backtrace
 
static ID id_key
 
static ID id_matchee
 
static ID id_args
 
static ID id_Errno
 
static ID id_errno
 
static ID id_i_path
 
static ID id_receiver
 
static ID id_recv
 
static ID id_iseq
 
static ID id_local_variables
 
static ID id_private_call_p
 
static ID id_top
 
static ID id_bottom
 
static const rb_data_type_t name_err_mesg_data_type
 
static st_tablesyserr_tbl
 
VALUE rb_eException
 Mother of all exceptions. More...
 
VALUE rb_eStandardError
 StandardError exception. More...
 
VALUE rb_eSystemExit
 SystemExit exception. More...
 
VALUE rb_eInterrupt
 Interrupt exception. More...
 
VALUE rb_eSignal
 SignalException exception. More...
 
VALUE rb_eFatal
 fatal exception. More...
 
VALUE rb_eArgError
 ArgumentError exception. More...
 
VALUE rb_eEOFError
 EOFError exception. More...
 
VALUE rb_eIndexError
 IndexError exception. More...
 
VALUE rb_eStopIteration
 StopIteration exception. More...
 
VALUE rb_eKeyError
 KeyError exception. More...
 
VALUE rb_eRangeError
 RangeError exception. More...
 
VALUE rb_eIOError
 IOError exception. More...
 
VALUE rb_eRuntimeError
 RuntimeError exception. More...
 
VALUE rb_eFrozenError
 FrozenError exception. More...
 
VALUE rb_eSecurityError
 SecurityError exception. More...
 
VALUE rb_eSystemCallError
 SystemCallError exception. More...
 
VALUE rb_eThreadError
 ThreadError exception. More...
 
VALUE rb_eTypeError
 TypeError exception. More...
 
VALUE rb_eZeroDivError
 ZeroDivisionError exception. More...
 
VALUE rb_eNotImpError
 NotImplementedError exception. More...
 
VALUE rb_eNoMemError
 NoMemoryError exception. More...
 
VALUE rb_eNoMethodError
 NoMethodError exception. More...
 
VALUE rb_eFloatDomainError
 FloatDomainError exception. More...
 
VALUE rb_eLocalJumpError
 LocalJumpError exception. More...
 
VALUE rb_eSysStackError
 SystemStackError exception. More...
 
VALUE rb_eRegexpError
 RegexpError exception. More...
 
VALUE rb_eEncodingError
 EncodingError exception. More...
 
VALUE rb_eEncCompatError
 Encoding::CompatibilityError exception. More...
 
VALUE rb_eNoMatchingPatternError
 NoMatchingPatternError exception. More...
 
VALUE rb_eNoMatchingPatternKeyError
 NoMatchingPatternKeyError exception. More...
 
VALUE rb_eScriptError
 ScriptError exception. More...
 
VALUE rb_eNameError
 NameError exception. More...
 
VALUE rb_eSyntaxError
 SyntaxError exception. More...
 
VALUE rb_eLoadError
 LoadError exception. More...
 
VALUE rb_eMathDomainError
 Math::DomainError exception. More...
 

Detailed Description

Macro Definition Documentation

◆ bug_report_begin

#define bug_report_begin (   out,
  fmt 
)
Value:
do { \
va_list args; \
va_start(args, fmt); \
bug_report_begin_valist(out, fmt, args); \
va_end(args); \
} while (0)

Definition at line 1005 of file error.c.

◆ report_bug

#define report_bug (   file,
  line,
  fmt,
  ctx 
)
Value:
do { \
rb_pid_t pid = -1; \
FILE *out = bug_report_file(file, line, &pid); \
if (out) { \
bug_report_begin(out, fmt); \
rb_vm_bugreport(ctx, out); \
bug_report_end(out, pid); \
} \
} while (0) \

Definition at line 1027 of file error.c.

◆ report_bug_valist

#define report_bug_valist (   file,
  line,
  fmt,
  ctx,
  args 
)
Value:
do { \
rb_pid_t pid = -1; \
FILE *out = bug_report_file(file, line, &pid); \
if (out) { \
bug_report_begin_valist(out, fmt, args); \
rb_vm_bugreport(ctx, out); \
bug_report_end(out, pid); \
} \
} while (0) \

Definition at line 1037 of file error.c.

◆ ruby_debug

#define ruby_debug   (*rb_ruby_debug_ptr())

This variable controls whether the interpreter is in debug mode.

Setting this to some truthy value is equivalent to passing -d flag to the interpreter.

Return values
QnilInterpreter not in debug mode.
QfalseInterpreter not in debug mode.
otherwiseInterpreter is in debug mode.

Definition at line 486 of file error.h.

◆ ruby_verbose

#define ruby_verbose   (*rb_ruby_verbose_ptr())

This variable controls whether the interpreter is in debug mode.

Setting this to some truthy value is equivalent to passing -W flag to the interpreter. Setting this to Qfalse is equivalent to passing -W1 flag to the interpreter. Setting this to Qnil is equivalent to passing -W0 flag to the interpreter.

Return values
QnilInterpreter is quiet.
QfalseInterpreter is kind of chatty.
otherwiseInterpreter is very verbose.

Definition at line 475 of file error.h.

◆ with_warn_vsprintf

#define with_warn_vsprintf (   enc,
  file,
  line,
  fmt 
)
Value:
VALUE str; \
va_list args; \
va_start(args, fmt); \
str = warn_vsprintf(enc, file, line, fmt, args); \
va_end(args);
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40

Definition at line 389 of file error.c.

◆ with_warning_string_from

#define with_warning_string_from (   mesg,
  enc,
  fmt,
  last_arg 
)
Value:
VALUE mesg; \
va_list args; va_start(args, last_arg); \
mesg = warning_string(enc, fmt, args); \
va_end(args);

Definition at line 459 of file error.c.

Enumeration Type Documentation

◆ rb_io_wait_readwrite

for rb_readwrite_sys_fail first argument

Definition at line 73 of file error.h.

◆ rb_warning_category_t

Warning categories.

A warning issued using this API can be selectively requested / suppressed by the end-users. For instance passing -W:no-deprecated to the ruby process would suppress those warnings in deprecated category.

Warning
There is no way to declare a new category (for now).
Enumerator
RB_WARN_CATEGORY_NONE 

Category unspecified.

RB_WARN_CATEGORY_DEPRECATED 

Warning is for deprecated features.

RB_WARN_CATEGORY_EXPERIMENTAL 

Warning is for experimental features.

RB_WARN_CATEGORY_PERFORMANCE 

Warning is for performance issues (not enabled by -w).

RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK 

Warning is for checking unused block strictly.

Definition at line 43 of file error.h.

Function Documentation

◆ rb_bug()

void rb_bug ( const char *  fmt,
  ... 
)

Interpreter panic switch.

Immediate process termination without any synchronisations shall occur. LOTS of internal states, stack traces, and even machine registers are displayed if possible for debugging purposes then.

Warning
Do not use this API.
You are not expected to use this API.
Why not just fix your code instead of calling this API?
It was a bad idea to expose this API to extension libraries at the first place. We just cannot delete it at this point for backwards compatibility. That doesn't mean everyone are welcomed to call this function at will.
Parameters
[in]fmtFormat specifier string compatible with rb_sprintf().
Note
It never returns.

Definition at line 1089 of file error.c.

Referenced by rb_bug_errno(), rb_check_type(), rb_econv_open_opts(), rb_fix2str(), rb_obj_freeze(), rb_str_set_len(), rb_thread_call_with_gvl(), rb_tracearg_object(), rb_tracearg_raised_exception(), rb_tracearg_return_value(), rb_unexpected_type(), and rb_update_max_fd().

◆ rb_bug_errno()

void rb_bug_errno ( const char *  msg,
int  err 
)

This is a wrapper of rb_bug() which automatically constructs appropriate message from the passed errno.

Parameters
[in]msgAdditional message to display.
Exceptions
errC level errno.
Note
It never returns.

Definition at line 1118 of file error.c.

◆ rb_category_compile_warn()

void rb_category_compile_warn ( rb_warning_category_t  cat,
const char *  file,
int  line,
const char *  fmt,
  ... 
)

Identical to rb_compile_warn(), except it also accepts category.

Parameters
[in]catCategory e.g. deprecated.
[in]fileThe path corresponding to Ruby level __FILE__.
[in]lineThe number corresponding to Ruby level __LINE__.
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 439 of file error.c.

◆ rb_category_warn()

void rb_category_warn ( rb_warning_category_t  cat,
const char *  fmt,
  ... 
)

Identical to rb_category_warning(), except it reports unless $VERBOSE is nil.

Parameters
[in]catCategory e.g. deprecated.
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 476 of file error.c.

Referenced by rb_io_print().

◆ rb_category_warning()

void rb_category_warning ( rb_warning_category_t  cat,
const char *  fmt,
  ... 
)

Identical to rb_warning(), except it takes additional "category" parameter.

Parameters
[in]catName of a known category.
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 508 of file error.c.

◆ rb_check_copyable()

void rb_check_copyable ( VALUE  obj,
VALUE  orig 
)

Ensures that the passed object can be initialize_copy relationship.

When you implement your own one you would better call this at the right beginning of your implementation.

Parameters
[in]objDestination object.
[in]origSource object.
Exceptions
rb_eFrozenErrorobj is frozen.
Postcondition
Upon successful return obj is guaranteed safe to copy orig.

Definition at line 4068 of file error.c.

◆ rb_check_frozen()

void rb_check_frozen ( VALUE  obj)

Queries if the passed object is frozen.

Parameters
[in]objTarget object to test frozen-ness.
Exceptions
rb_eFrozenErrorIt is frozen.
Postcondition
Upon successful return it is guaranteed not frozen.

Definition at line 4062 of file error.c.

Referenced by rb_check_copyable().

◆ rb_check_type()

void rb_check_type ( VALUE  obj,
int  t 
)

This was the old implementation of Check_Type(), but they diverged.

This one remains for theoretical backwards compatibility. People normally need not use it.

Parameters
[in]objAn object.
[in]tA type.
Exceptions
rb_eTypeErrorobj is not of type t.
rb_eFatalobj is corrupt.
Postcondition
Upon successful return obj is guaranteed to have type t.

Definition at line 1315 of file error.c.

◆ rb_check_typeddata()

void* rb_check_typeddata ( VALUE  obj,
const rb_data_type_t data_type 
)

Identical to rb_typeddata_is_kind_of(), except it raises exceptions instead of returning false.

Parameters
[in]objAn instance of RTypedData.
[in]data_typeExpected data type of obj.
Exceptions
rb_eTypeErrorobj is not of data_type.
Returns
Unwrapped C struct that obj holds.
Postcondition
Upon successful return obj's type is guaranteed data_type.

Definition at line 1375 of file error.c.

Referenced by rb_waitpid().

◆ rb_compile_warn()

void rb_compile_warn ( const char *  file,
int  line,
const char *  fmt,
  ... 
)

Identical to rb_compile_warning(), except it reports unless $VERBOSE is nil.

Parameters
[in]fileThe path corresponding to Ruby level __FILE__.
[in]lineThe number corresponding to Ruby level __LINE__.
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 397 of file error.c.

◆ rb_compile_warning()

void rb_compile_warning ( const char *  file,
int  line,
const char *  fmt,
  ... 
)

Issues a compile-time warning that happens at __file__:__line__.

Purpose of this function being exposed to CAPI is unclear.

Note
This function is affected by the value of $VERBOSE.
Parameters
[in]fileThe path corresponding to Ruby level __FILE__.
[in]lineThe number corresponding to Ruby level __LINE__.
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 418 of file error.c.

◆ rb_enc_raise()

void rb_enc_raise ( rb_encoding enc,
VALUE  exc,
const char *  fmt,
  ... 
)

Identical to rb_raise(), except it additionally takes an encoding.

Parameters
[in]encEncoding of the generating exception.
[in]excA subclass of rb_eException.
[in]fmtFormat specifier string compatible with rb_sprintf().
[in]...Contents of the message.
Exceptions
excThe specified exception.
Note
It never returns.

Definition at line 3616 of file error.c.

Referenced by rb_str_format().

◆ rb_ensure()

VALUE rb_ensure ( VALUE(*)(VALUE b_proc,
VALUE  data1,
VALUE(*)(VALUE e_proc,
VALUE  data2 
)

An equivalent to ensure clause.

Calls the function b_proc with data1 as the argument, then calls e_proc with data2 when execution terminated.

Parameters
[in]b_procA function representing begin clause.
[in,out]data1Passed to b_proc.
[in]e_procA function representing ensure clause.
[in,out]data2Passed to e_proc.
Return values
RUBY_Qnilexception occurred inside of b_proc.
otherwiseThe return value of b_proc.
See also
rb_rescue
rb_rescue2
rb_protect

Definition at line 1045 of file eval.c.

Referenced by rb_fiber_scheduler_set(), rb_mutex_sleep(), rb_mutex_synchronize(), and rb_thread_fd_select().

◆ rb_errinfo()

VALUE rb_errinfo ( void  )

This is the same as $! in Ruby.

Return values
RUBY_QnilNot handling exceptions at the moment.
otherwiseThe current exception in the current thread.

Definition at line 1920 of file eval.c.

◆ rb_error_frozen()

void rb_error_frozen ( const char *  what)

Identical to rb_frozen_error_raise(), except its raising exception has a message like "can't modify frozen /what/".

Parameters
[in]whatWhat was frozen.
Exceptions
rb_eFrozenErrorAlways raises this.
Note
It never returns.

Definition at line 3954 of file error.c.

◆ rb_error_frozen_object()

void rb_error_frozen_object ( VALUE  what)

Identical to rb_error_frozen(), except it takes arbitrary Ruby object instead of C's string.

Parameters
[in]whatWhat was frozen.
Exceptions
rb_eFrozenErrorAlways raises this.
Note
It never returns.

Definition at line 4000 of file error.c.

Referenced by rb_check_frozen_inline().

◆ rb_exc_fatal()

void rb_exc_fatal ( VALUE  mesg)

Raises a fatal error in the current thread.

Identical to rb_fatal(), except it raises the passed exception instance as- is instead of creating new one.

Same as rb_exc_raise() but raises a fatal error, which Ruby codes cannot rescue.

Definition at line 689 of file eval.c.

◆ rb_exc_new()

VALUE rb_exc_new ( VALUE  etype,
const char *  ptr,
long  len 
)

Creates an instance of the passed exception class.

Parameters
[in]etypeA subclass of rb_eException.
[in]ptrBuffer contains error message.
[in]lenLength of ptr, in bytes, not including the terminating NUL character.
Exceptions
rb_eTypeErroretype is not a class.
rb_eArgErrorlen is negative.
Returns
An instance of etype.
Precondition
At least len bytes of continuous memory region shall be accessible via ptr.

Definition at line 1446 of file error.c.

Referenced by rb_exc_new_cstr(), and rb_interrupt().

◆ rb_exc_new_cstr()

VALUE rb_exc_new_cstr ( VALUE  etype,
const char *  str 
)

Identical to rb_exc_new(), except it assumes the passed pointer is a pointer to a C string.

Parameters
[in]etypeA subclass of rb_eException.
[in]strA C string (becomes an error message).
Exceptions
rb_eTypeErroretype is not a class.
Returns
An instance of etype.

Definition at line 1453 of file error.c.

◆ rb_exc_new_str()

VALUE rb_exc_new_str ( VALUE  etype,
VALUE  str 
)

Identical to rb_exc_new_cstr(), except it takes a Ruby's string instead of C's.

Parameters
[in]etypeA subclass of rb_eException.
[in]strAn instance of rb_cString.
Exceptions
rb_eTypeErroretype is not a class.
Returns
An instance of etype.

Definition at line 1459 of file error.c.

Referenced by rb_error_frozen_object().

◆ rb_exc_raise()

void rb_exc_raise ( VALUE  mesg)

Raises an exception in the current thread.

Identical to rb_raise(), except it raises the passed exception instance as- is instead of creating new one.

Parameters
[in]mesgan Exception class or an Exception object.
Exceptions
alwaysraises an instance of the given exception class or the given Exception object.

Definition at line 676 of file eval.c.

Referenced by rb_econv_check_error(), rb_enc_raise(), rb_exit(), rb_f_abort(), rb_interrupt(), rb_name_error(), rb_name_error_str(), rb_raise(), rb_sys_fail(), rb_sys_fail_str(), rb_syserr_fail(), rb_syserr_fail_str(), and rb_throw_obj().

◆ rb_exit()

void rb_exit ( int  status)

Terminates the current execution context.

This API is the entry point of a "well-mannered" termination sequence. When called from an extension library, it raises rb_eSystemExit exception. Programs could rescue that exception. Can cancel process exit then. Otherwise, that exception results in a process termination with the status passed to this function.

Parameters
[in]statusExit status, see also exit(3).
Exceptions
rb_eSystemExitException representing the exit status.
Note
It never returns.

Definition at line 4454 of file process.c.

Referenced by rb_f_abort(), and rb_thread_kill().

◆ rb_fatal()

void rb_fatal ( const char *  fmt,
  ... 
)

Raises the unsung "fatal" exception.

This is considered severe. Nobody can rescue the exception. Once raised, process termination is inevitable. However ensure clauses still run, so that resources are properly cleaned up.

Parameters
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
rb_eFatalAn exception that you cannot rescue.
Note
It never returns.

Definition at line 3687 of file error.c.

◆ rb_frozen_error_raise()

void rb_frozen_error_raise ( VALUE  recv,
const char *  fmt,
  ... 
)

Raises an instance of rb_eFrozenError.

The object can be obtained later using FrozenError#receiver of the raising exception.

Parameters
[in]recvWhat is frozen.
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
rb_eFrozenErrorAlways raises this.
Note
It never returns.

Definition at line 3960 of file error.c.

Referenced by rb_thread_local_aset().

◆ rb_invalid_str()

void rb_invalid_str ( const char *  str,
const char *  type 
)

Honestly I don't understand the name, but it raises an instance of rb_eArgError.

Parameters
[in]strA message.
[in]typeAnother message.
Exceptions
rb_eArgErrorAlways raises this.
Note
It never returns.

Definition at line 2654 of file error.c.

Referenced by rb_cstr_to_inum().

◆ rb_iter_break()

void rb_iter_break ( void  )

Breaks from a block.

Because you are using a CAPI this is not as intuitive as it sounds. In order for this function to properly work, make a rb_block_call_func_t function that calls it internally, and pass that function to rb_block_call().

Exceptions
rb_eLocalJumpErrorCalled from outside of a block.
Note
It never returns.

Definition at line 2076 of file vm.c.

◆ rb_iter_break_value()

void rb_iter_break_value ( VALUE  val)

Identical to rb_iter_break(), except it additionally takes the "value" of this breakage.

It will be the evaluation result of the iterator. This is kind of complicated; you cannot see this as a "return from a block" behaviour. Take a look at this example:

def foo(q)
puts(w = yield(q))
puts(e = yield(w))
puts(r = yield(e))
puts(t = yield(r))
puts(y = yield(t))
return "howdy!"
end
x = foo(0) {|i|
if i > 2
break "hello!"
else
next i + 1
end
}
puts x

This script outputs 1, 2, 3, and hello. Note that the value passed to break becomes the return value of foo method, not the value of yield. This is confusing, but can be handy on occasions e.g. when you want to bring a local variable out of a block.

Parameters
[in]valThe value of the iterator.
Exceptions
rb_eLocalJumpErrorCalled from outside of a block.
Note
It never returns.

Definition at line 2082 of file vm.c.

◆ rb_loaderror()

void rb_loaderror ( const char *  fmt,
  ... 
)

Raises an instance of rb_eLoadError.

Parameters
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
rb_eLoadErrorAlways raises this.
Note
It never returns.

Definition at line 3655 of file error.c.

◆ rb_loaderror_with_path()

void rb_loaderror_with_path ( VALUE  path,
const char *  fmt,
  ... 
)

Identical to rb_loaderror(), except it additionally takes which file is unable to load.

The path can be obtained later using LoadError#path of the raising exception.

Parameters
[in]pathWhat failed.
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
rb_eLoadErrorAlways raises this.
Note
It never returns.

Definition at line 3667 of file error.c.

◆ rb_mod_sys_fail()

void rb_mod_sys_fail ( VALUE  mod,
const char *  msg 
)

Identical to rb_sys_fail(), except it takes additional module to extend the exception object before raising.

Parameters
[in]modA rb_cModule instance.
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing errno.
Note
It never returns.

Definition at line 3817 of file error.c.

◆ rb_mod_sys_fail_str()

void rb_mod_sys_fail_str ( VALUE  mod,
VALUE  msg 
)

Identical to rb_mod_sys_fail(), except it takes the message in Ruby's String instead of C's.

Parameters
[in]modA rb_cModule instance.
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing errno.
Note
It never returns.

Definition at line 3824 of file error.c.

◆ rb_mod_syserr_fail()

void rb_mod_syserr_fail ( VALUE  mod,
int  err,
const char *  msg 
)

Identical to rb_mod_sys_fail(), except it does not depend on C global variable errno.

Pass it explicitly.

Parameters
[in]modA rb_cModule instance.
[in]errC level errno.
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing err.
Note
It never returns.

Definition at line 3831 of file error.c.

◆ rb_mod_syserr_fail_str()

void rb_mod_syserr_fail_str ( VALUE  mod,
int  err,
VALUE  msg 
)

Identical to rb_mod_syserr_fail(), except it takes the message in Ruby's String instead of C's.

Parameters
[in]modA rb_cModule instance.
[in]errC level errno.
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing err.
Note
It never returns.

Definition at line 3838 of file error.c.

◆ rb_name_error()

void rb_name_error ( ID  name,
const char *  fmt,
  ... 
)

Raises an instance of rb_eNameError.

The name can be obtained later using NameError#name of the raising exception.

Parameters
[in]nameWhat failed.
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
rb_eNameErrorAlways raises this.
Note
It never returns.

Definition at line 2215 of file error.c.

Referenced by rb_f_untrace_var(), and rb_id_attrset().

◆ rb_name_error_str()

void rb_name_error_str ( VALUE  name,
const char *  fmt,
  ... 
)

Identical to rb_name_error(), except it takes a VALUE instead of ID.

Parameters
[in]nameWhat failed.
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
rb_eNameErrorAlways raises this.
Note
It never returns.

Definition at line 2230 of file error.c.

Referenced by rb_f_untrace_var(), and rb_id_attrset().

◆ rb_notimplement()

void rb_notimplement ( void  )
Exceptions
rb_eNotImpError
Note
It never returns.

Definition at line 3679 of file error.c.

◆ rb_raise()

void rb_raise ( VALUE  exc,
const char *  fmt,
  ... 
)

Exception entry point.

By calling this function the execution of your program gets interrupted to "raise" an exception up to the callee entities. Programs could "rescue" that exception, or could "ensure" some part of them. If nobody cares about such things, the raised exception reaches at the top of execution. This yields abnormal end of the process.

Parameters
[in]excA subclass of rb_eException.
[in]fmtFormat specifier string compatible with rb_sprintf().
Exceptions
excThe specified exception.
Note
It never returns.

Definition at line 3635 of file error.c.

Referenced by rb_alias(), rb_alias_variable(), rb_ary_resize(), rb_ary_store(), rb_big2long(), rb_big2ulong(), rb_big_pow(), rb_check_id(), rb_check_inheritable(), rb_check_symbol(), rb_class_attached_object(), rb_class_inherited_p(), rb_class_superclass(), rb_cmperr(), rb_current_receiver(), rb_define_module_id_under(), rb_econv_append(), rb_econv_prepare_options(), rb_enc_codelen(), rb_enc_codepoint_len(), rb_enc_find_index(), rb_enc_set_default_external(), rb_enc_str_new_cstr(), rb_enc_uint_chr(), rb_enc_vsprintf(), rb_error_frozen(), rb_f_global_variables(), rb_fix2str(), rb_gc_latest_gc_info(), rb_gc_stat(), rb_Hash(), rb_integer_unpack(), rb_internal_thread_specific_key_create(), rb_invalid_str(), rb_io_check_byte_readable(), rb_io_check_char_readable(), rb_io_check_initialized(), rb_io_check_writable(), rb_io_descriptor(), rb_io_extract_modeenc(), rb_io_maybe_wait_readable(), rb_io_maybe_wait_writable(), rb_io_modestr_fmode(), rb_io_ungetc(), rb_memory_view_prepare_item_desc(), rb_method_call_with_block_kw(), rb_must_asciicompat(), rb_mutex_unlock(), rb_notimplement(), rb_num2fix(), rb_num2long(), rb_num_zerodiv(), rb_obj_encoding(), rb_out_of_int(), rb_random_real(), rb_random_ulong_limited(), rb_range_beg_len(), rb_reg_onig_match(), rb_reg_prepare_re(), rb_reg_regsub(), rb_set_errinfo(), rb_str_cat(), rb_str_concat(), rb_str_dump(), rb_str_ellipsize(), rb_str_format(), rb_str_modify_expand(), rb_str_plus(), rb_str_resize(), rb_str_set_len(), rb_str_times(), rb_str_unlocktmp(), rb_str_update(), rb_string_value_cstr(), rb_struct_members(), rb_struct_s_members(), rb_sym2id(), rb_thread_stop(), rb_thread_wakeup(), rb_time_timespec_new(), rb_tracearg_object(), rb_tracearg_raised_exception(), rb_tracearg_return_value(), rb_tracepoint_enable(), rb_undef(), rb_uv_to_utf8(), rb_yield_splat(), and rb_yield_splat_kw().

◆ rb_readwrite_sys_fail()

void rb_readwrite_sys_fail ( enum rb_io_wait_readwrite  waiting,
const char *  msg 
)

Raises appropriate exception using the parameters.

In Ruby level there are rb_eEAGAINWaitReadable etc. This function maps the given parameter to an appropriate exception class, then raises it.

Parameters
[in]waitingReason for the IO to wait.
[in]msgAdditional message to raise.
Exceptions
rb_eEAGAINWaitWritable
rb_eEWOULDBLOCKWaitWritable
rb_eEINPROGRESSWaitWritable
rb_eEAGAINWaitReadable
rb_eEWOULDBLOCKWaitReadable
rb_eEINPROGRESSWaitReadable
rb_eSystemCallError
Note
It never returns.

Definition at line 14620 of file io.c.

◆ rb_readwrite_syserr_fail()

void rb_readwrite_syserr_fail ( enum rb_io_wait_readwrite  waiting,
int  err,
const char *  msg 
)

Identical to rb_readwrite_sys_fail(), except it does not depend on C global variable errno.

Pass it explicitly.

Parameters
[in]waitingReason for the IO to wait.
[in]errC level errno.
[in]msgAdditional message to raise.
Exceptions
rb_eEAGAINWaitWritable
rb_eEWOULDBLOCKWaitWritable
rb_eEINPROGRESSWaitWritable
rb_eEAGAINWaitReadable
rb_eEWOULDBLOCKWaitReadable
rb_eEINPROGRESSWaitReadable
rb_eSystemCallError
Note
It never returns.

Definition at line 14626 of file io.c.

Referenced by rb_readwrite_sys_fail().

◆ rb_rescue()

VALUE rb_rescue ( VALUE(*)(VALUE b_proc,
VALUE  data1,
VALUE(*)(VALUE, VALUE r_proc,
VALUE  data2 
)

Identical to rb_rescue2(), except it does not take a list of exception classes.

This is a shorthand of:

rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError, (VALUE)0);
VALUE rb_rescue2(VALUE(*b_proc)(VALUE), VALUE data1, VALUE(*r_proc)(VALUE, VALUE), VALUE data2,...)
An equivalent of rescue clause.
Definition: eval.c:945
VALUE rb_eStandardError
StandardError exception.
Definition: error.c:1405
Parameters
[in]b_procA function which potentially raises an exception.
[in,out]data1Passed to b_proc.
[in]r_procA function which rescues an exception in b_proc.
[in,out]data2The first argument of r_proc.
Returns
The return value of b_proc if no exception occurs, or the return value of r_proc otherwise.
See also
rb_rescue
rb_ensure
rb_protect

Definition at line 1016 of file eval.c.

◆ rb_rescue2()

VALUE rb_rescue2 ( VALUE(*)(VALUE b_proc,
VALUE  data1,
VALUE(*)(VALUE, VALUE r_proc,
VALUE  data2,
  ... 
)

An equivalent of rescue clause.

First it calls the function b_proc with data1 as the argument. If nothing is thrown the function happily returns the return value of b_proc. When b_proc raises an exception, and the exception is a kind of one of the given exception classes, it then calls r_proc with data2 and that exception. If the exception does not match any of them, it propagates.

Parameters
[in]b_procA function which potentially raises an exception.
[in,out]data1Passed to b_proc.
[in]r_procA function which rescues an exception in b_proc.
[in,out]data2The first argument of r_proc.
[in]...1 or more exception classes. Must be terminated by (VALUE)0
Returns
The return value of b_proc if no exception occurs, or the return value of r_proc otherwise.
See also
rb_rescue
rb_ensure
rb_protect

Definition at line 945 of file eval.c.

Referenced by rb_rescue().

◆ rb_set_errinfo()

void rb_set_errinfo ( VALUE  err)

Sets the current exception ($!) to the given value.

Parameters
[in]errAn instance of rb_eException, or RUBY_Qnil.
Exceptions
rb_eTypeErrorWhat is given was neither rb_eException nor RUBY_Qnil.
Note
Use rb_raise() instead to raise err. This function just assigns the given object to the global variable.

Definition at line 1926 of file eval.c.

◆ rb_sys_fail()

void rb_sys_fail ( const char *  msg)

Converts a C errno into a Ruby exception, then raises it.

For instance:

static VALUE
foo(VALUE argv)
{
const auto cmd = StringValueCStr(argv);
const auto waitr = system(cmd);
if (waitr == -1) {
rb_sys_fail("system(3posix)"); // <-------------- this
}
else {
return INT2FIX(fd);
}
}
#define INT2FIX
Old name of RB_INT2FIX.
Definition: long.h:48
void rb_sys_fail(const char *mesg)
Converts a C errno into a Ruby exception, then raises it.
Definition: error.c:3761
#define StringValueCStr(v)
Identical to StringValuePtr, except it additionally checks for the contents for viability as a C stri...
Definition: rstring.h:89
Parameters
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing errno.
Note
It never returns.

Definition at line 3761 of file error.c.

Referenced by rb_f_kill(), rb_io_wait(), and rb_timespec_now().

◆ rb_sys_fail_str()

void rb_sys_fail_str ( VALUE  msg)

Identical to rb_sys_fail(), except it takes the message in Ruby's String instead of C's.

Parameters
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing errno.
Note
It never returns.

Definition at line 3768 of file error.c.

◆ rb_sys_warning()

void rb_sys_warning ( const char *  fmt,
  ... 
)

Identical to rb_sys_fail(), except it does not raise an exception to render a warning instead.

Note
This function is affected by the value of $VERBOSE.
Parameters
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 3899 of file error.c.

◆ rb_syserr_fail()

void rb_syserr_fail ( int  err,
const char *  msg 
)

Raises appropriate exception that represents a C errno.

Parameters
[in]errC level errno.
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing err.
Note
It never returns.

Definition at line 3748 of file error.c.

Referenced by rb_fdopen(), and ruby_getcwd().

◆ rb_syserr_fail_str()

void rb_syserr_fail_str ( int  err,
VALUE  msg 
)

Identical to rb_syserr_fail(), except it takes the message in Ruby's String instead of C's.

Parameters
[in]errC level errno.
[in]msgAdditional message to raise.
Exceptions
rb_eSystemCallErrorAn exception representing err.
Note
It never returns.

Definition at line 3754 of file error.c.

Referenced by rb_f_exec().

◆ rb_syserr_new()

VALUE rb_syserr_new ( int  err,
const char *  msg 
)

Creates an exception object that represents the given C errno.

Parameters
[in]errC level errno.
[in]msgAdditional message.
Return values
rb_eSystemCallErrorAn exception for the errno.

Definition at line 3734 of file error.c.

Referenced by rb_mod_syserr_fail(), and rb_syserr_fail().

◆ rb_syserr_new_str()

VALUE rb_syserr_new_str ( int  n,
VALUE  arg 
)

Identical to rb_syserr_new(), except it takes the message in Ruby's String instead of C's.

Parameters
[in]nC level errno.
[in]argAdditional message.
Return values
rb_eSystemCallErrorAn exception for the errno.

Definition at line 3742 of file error.c.

Referenced by rb_mod_syserr_fail_str(), rb_syserr_fail_str(), and rb_syserr_new().

◆ rb_typeddata_inherited_p()

int rb_typeddata_inherited_p ( const rb_data_type_t child,
const rb_data_type_t parent 
)

Checks for the domestic relationship between the two.

Parameters
[in]childA data type supposed to be a child of parent.
[in]parentA data type supposed to be a parent of child.
Return values
truechild is a descendent of parent.
falseOtherwise.

Definition at line 1348 of file error.c.

Referenced by rb_typeddata_is_kind_of().

◆ rb_typeddata_is_kind_of()

int rb_typeddata_is_kind_of ( VALUE  obj,
const rb_data_type_t data_type 
)

Checks if the given object is of given kind.

Parameters
[in]objAn instance of RTypedData.
[in]data_typeExpected data type of obj.
Return values
trueobj is of data_type.
falseOtherwise.

Definition at line 1358 of file error.c.

Referenced by rb_obj_is_fiber(), rb_obj_is_method(), and rb_obj_is_proc().

◆ rb_unexpected_type()

void rb_unexpected_type ( VALUE  self,
int  t 
)

Fails with the given object's type incompatibility to the type.

It seems this function is visible from extension libraries only because RTYPEDDATA_TYPE() uses it on RUBY_DEBUG. So you can basically ignore it; use some other fine-grained method instead.

Parameters
[in]selfThe object in question.
[in]tExpected type of the object.
Exceptions
rb_eTypeErrorself not in type t.
Note
It never returns.
The second argument must have been an enum ruby_value_type, but for historical reasons it remains to be an int (in other words we see no benefits fixing this bug).

Definition at line 1338 of file error.c.

Referenced by RTYPEDDATA_TYPE().

◆ rb_vrescue2()

VALUE rb_vrescue2 ( VALUE(*)(VALUE b_proc,
VALUE  data1,
VALUE(*)(VALUE, VALUE r_proc,
VALUE  data2,
va_list  ap 
)

Identical to rb_rescue2(), except it takes va_list instead of variadic number of arguments.

This is exposed to 3rd parties because inline functions use it. Basically you don't have to bother.

Parameters
[in]b_procA function which potentially raises an exception.
[in,out]data1Passed to b_proc.
[in]r_procA function which rescues an exception in b_proc.
[in,out]data2The first argument of r_proc.
[in]ap1 or more exception classes. Must be terminated by (VALUE)0
Returns
The return value of b_proc if no exception occurs, or the return value of r_proc otherwise.
See also
rb_rescue
rb_ensure
rb_protect

Definition at line 956 of file eval.c.

Referenced by ruby::backward::cxxanyargs::rb_rescue2(), and rb_rescue2().

◆ rb_warn()

void rb_warn ( const char *  fmt,
  ... 
)

Identical to rb_warning(), except it reports unless $VERBOSE is nil.

Note
This function is affected by the value of $VERBOSE, it does nothing if $VERBOSE is nil.
Parameters
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 466 of file error.c.

Referenced by rb_complex_pow(), rb_define_const(), rb_enc_find_index(), rb_fdopen(), rb_gc_register_address(), rb_io_extract_encoding_option(), rb_str_format(), and rb_undef().

◆ rb_warning()

void rb_warning ( const char *  fmt,
  ... 
)

Issues a warning.

In ruby, warnings these days are tightly coupled with the rb_mWarning constant and its warn singleton method. This CAPI is just a thin wrapper of it; everything passed are formatted like what rb_sprintf() does, then passed through to the method. Programs can have their own def Warning.warn at will to do whatever they want, from ignoring the warnings at all to sinking them to some BigQuery data set via a Fluentd cluster. By default, the method just emits its passed contents to rb_stderr using rb_io_write().

Note
This function is affected by the value of $VERBOSE, it does nothing unless $VERBOSE is true.
Parameters
[in]fmtFormat specifier string compatible with rb_sprintf().

Definition at line 497 of file error.c.

Referenced by rb_attr(), rb_big2dbl(), rb_gv_get(), and rb_memory_view_register().

Variable Documentation

◆ name_err_mesg_data_type

const rb_data_type_t name_err_mesg_data_type
static
Initial value:
= {
"name_err_mesg",
{
name_err_mesg_mark,
NULL,
name_err_mesg_update,
},
0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
}
#define RUBY_TYPED_DEFAULT_FREE
This is a value you can set to rb_data_type_struct::dfree.
Definition: rtypeddata.h:79

Definition at line 2408 of file error.c.

◆ rb_cNameErrorMesg

VALUE rb_cNameErrorMesg

NameError::Message class.

Definition at line 1420 of file error.c.

◆ rb_eArgError [1/2]

VALUE rb_eArgError

◆ rb_eArgError [2/2]

VALUE rb_eArgError
extern

◆ rb_eEncCompatError [1/2]

VALUE rb_eEncCompatError

Encoding::CompatibilityError exception.

Definition at line 1415 of file error.c.

Referenced by rb_must_asciicompat().

◆ rb_eEncCompatError [2/2]

VALUE rb_eEncCompatError
extern

Encoding::CompatibilityError exception.

Definition at line 1415 of file error.c.

Referenced by rb_must_asciicompat().

◆ rb_eEncodingError [1/2]

VALUE rb_eEncodingError

EncodingError exception.

Definition at line 1414 of file error.c.

◆ rb_eEncodingError [2/2]

VALUE rb_eEncodingError
extern

EncodingError exception.

Definition at line 1414 of file error.c.

◆ rb_eEOFError

VALUE rb_eEOFError
extern

EOFError exception.

Definition at line 188 of file io.c.

◆ rb_eException [1/2]

VALUE rb_eException

Mother of all exceptions.

Definition at line 1400 of file error.c.

Referenced by rb_set_errinfo().

◆ rb_eException [2/2]

VALUE rb_eException
extern

Mother of all exceptions.

Definition at line 1400 of file error.c.

Referenced by rb_set_errinfo().

◆ rb_eFatal [1/2]

VALUE rb_eFatal

fatal exception.

Definition at line 1404 of file error.c.

◆ rb_eFatal [2/2]

VALUE rb_eFatal
extern

fatal exception.

Definition at line 1404 of file error.c.

◆ rb_eFloatDomainError

VALUE rb_eFloatDomainError
extern

FloatDomainError exception.

Definition at line 201 of file numeric.c.

◆ rb_eFrozenError [1/2]

VALUE rb_eFrozenError

FrozenError exception.

Definition at line 1407 of file error.c.

Referenced by rb_error_frozen(), rb_error_frozen_object(), and rb_frozen_error_raise().

◆ rb_eFrozenError [2/2]

VALUE rb_eFrozenError
extern

FrozenError exception.

Definition at line 1407 of file error.c.

Referenced by rb_error_frozen(), rb_error_frozen_object(), and rb_frozen_error_raise().

◆ rb_eIndexError [1/2]

VALUE rb_eIndexError

IndexError exception.

Definition at line 1410 of file error.c.

Referenced by rb_ary_resize(), rb_ary_store(), rb_str_ellipsize(), and rb_str_update().

◆ rb_eIndexError [2/2]

VALUE rb_eIndexError
extern

IndexError exception.

Definition at line 1410 of file error.c.

Referenced by rb_ary_resize(), rb_ary_store(), rb_str_ellipsize(), and rb_str_update().

◆ rb_eInterrupt [1/2]

VALUE rb_eInterrupt

Interrupt exception.

Definition at line 1402 of file error.c.

Referenced by rb_interrupt().

◆ rb_eInterrupt [2/2]

VALUE rb_eInterrupt
extern

Interrupt exception.

Definition at line 1402 of file error.c.

Referenced by rb_interrupt().

◆ rb_eIOError

VALUE rb_eIOError
extern

◆ rb_eKeyError [1/2]

VALUE rb_eKeyError

KeyError exception.

Definition at line 1411 of file error.c.

◆ rb_eKeyError [2/2]

VALUE rb_eKeyError
extern

KeyError exception.

Definition at line 1411 of file error.c.

◆ rb_eLoadError [1/2]

VALUE rb_eLoadError

LoadError exception.

Definition at line 1426 of file error.c.

◆ rb_eLoadError [2/2]

VALUE rb_eLoadError
extern

LoadError exception.

Definition at line 1426 of file error.c.

◆ rb_eLocalJumpError

VALUE rb_eLocalJumpError
extern

LocalJumpError exception.

Definition at line 49 of file eval.c.

◆ rb_eMathDomainError

VALUE rb_eMathDomainError
extern

Math::DomainError exception.

Definition at line 30 of file math.c.

◆ rb_eNameError [1/2]

VALUE rb_eNameError

NameError exception.

Definition at line 1413 of file error.c.

Referenced by rb_name_error(), and rb_name_error_str().

◆ rb_eNameError [2/2]

VALUE rb_eNameError
extern

NameError exception.

Definition at line 1413 of file error.c.

Referenced by rb_name_error(), and rb_name_error_str().

◆ rb_eNoMatchingPatternError [1/2]

VALUE rb_eNoMatchingPatternError

NoMatchingPatternError exception.

Definition at line 1421 of file error.c.

◆ rb_eNoMatchingPatternError [2/2]

VALUE rb_eNoMatchingPatternError
extern

NoMatchingPatternError exception.

Definition at line 1421 of file error.c.

◆ rb_eNoMatchingPatternKeyError [1/2]

VALUE rb_eNoMatchingPatternKeyError

NoMatchingPatternKeyError exception.

Definition at line 1422 of file error.c.

◆ rb_eNoMatchingPatternKeyError [2/2]

VALUE rb_eNoMatchingPatternKeyError
extern

NoMatchingPatternKeyError exception.

Definition at line 1422 of file error.c.

◆ rb_eNoMemError [1/2]

VALUE rb_eNoMemError

NoMemoryError exception.

Definition at line 1419 of file error.c.

◆ rb_eNoMemError [2/2]

VALUE rb_eNoMemError
extern

NoMemoryError exception.

Definition at line 1419 of file error.c.

◆ rb_eNoMethodError [1/2]

VALUE rb_eNoMethodError

NoMethodError exception.

Definition at line 1416 of file error.c.

◆ rb_eNoMethodError [2/2]

VALUE rb_eNoMethodError
extern

NoMethodError exception.

Definition at line 1416 of file error.c.

◆ rb_eNotImpError [1/2]

VALUE rb_eNotImpError

NotImplementedError exception.

Definition at line 1418 of file error.c.

Referenced by rb_notimplement().

◆ rb_eNotImpError [2/2]

VALUE rb_eNotImpError
extern

NotImplementedError exception.

Definition at line 1418 of file error.c.

Referenced by rb_notimplement().

◆ rb_eRangeError [1/2]

VALUE rb_eRangeError

◆ rb_eRangeError [2/2]

VALUE rb_eRangeError
extern

◆ rb_eRegexpError

VALUE rb_eRegexpError
extern

RegexpError exception.

Definition at line 32 of file re.c.

◆ rb_eRuntimeError [1/2]

VALUE rb_eRuntimeError

◆ rb_eRuntimeError [2/2]

VALUE rb_eRuntimeError
extern

◆ rb_eScriptError [1/2]

VALUE rb_eScriptError

ScriptError exception.

Definition at line 1424 of file error.c.

◆ rb_eScriptError [2/2]

VALUE rb_eScriptError
extern

ScriptError exception.

Definition at line 1424 of file error.c.

◆ rb_eSecurityError [1/2]

VALUE rb_eSecurityError

SecurityError exception.

Definition at line 1417 of file error.c.

◆ rb_eSecurityError [2/2]

VALUE rb_eSecurityError
extern

SecurityError exception.

Definition at line 1417 of file error.c.

◆ rb_eSignal [1/2]

VALUE rb_eSignal

SignalException exception.

Definition at line 1403 of file error.c.

◆ rb_eSignal [2/2]

VALUE rb_eSignal
extern

SignalException exception.

Definition at line 1403 of file error.c.

◆ rb_eStandardError [1/2]

VALUE rb_eStandardError

StandardError exception.

Definition at line 1405 of file error.c.

Referenced by rb_rescue().

◆ rb_eStandardError [2/2]

VALUE rb_eStandardError
extern

StandardError exception.

Definition at line 1405 of file error.c.

Referenced by rb_rescue().

◆ rb_eStopIteration

VALUE rb_eStopIteration
extern

StopIteration exception.

Definition at line 181 of file enumerator.c.

◆ rb_eSyntaxError [1/2]

VALUE rb_eSyntaxError

SyntaxError exception.

Definition at line 1425 of file error.c.

◆ rb_eSyntaxError [2/2]

VALUE rb_eSyntaxError
extern

SyntaxError exception.

Definition at line 1425 of file error.c.

◆ rb_eSysStackError

VALUE rb_eSysStackError
extern

SystemStackError exception.

Definition at line 50 of file eval.c.

◆ rb_eSystemCallError [1/2]

VALUE rb_eSystemCallError

SystemCallError exception.

Definition at line 1428 of file error.c.

◆ rb_eSystemCallError [2/2]

VALUE rb_eSystemCallError
extern

SystemCallError exception.

Definition at line 1428 of file error.c.

◆ rb_eSystemExit [1/2]

VALUE rb_eSystemExit

SystemExit exception.

Definition at line 1401 of file error.c.

Referenced by rb_exit(), and rb_f_abort().

◆ rb_eSystemExit [2/2]

VALUE rb_eSystemExit
extern

SystemExit exception.

Definition at line 1401 of file error.c.

Referenced by rb_exit(), and rb_f_abort().

◆ rb_eThreadError

VALUE rb_eThreadError
extern

ThreadError exception.

Definition at line 934 of file eval.c.

Referenced by rb_internal_thread_specific_key_create(), rb_mutex_unlock(), rb_thread_stop(), and rb_thread_wakeup().

◆ rb_eTypeError [1/2]

VALUE rb_eTypeError

◆ rb_eTypeError [2/2]

VALUE rb_eTypeError
extern

◆ rb_eZeroDivError

VALUE rb_eZeroDivError
extern

ZeroDivisionError exception.

Definition at line 200 of file numeric.c.

Referenced by rb_num_zerodiv().

◆ rb_mErrno

VALUE rb_mErrno

Errno module.

Definition at line 1429 of file error.c.

◆ warning_disabled_categories

unsigned int warning_disabled_categories
static
Initial value:
= (
~RB_WARN_CATEGORY_DEFAULT_BITS)
@ RB_WARN_CATEGORY_DEPRECATED
Warning is for deprecated features.
Definition: error.h:48

Definition at line 160 of file error.c.