Ruby  3.1.4p223 (2023-03-30 revision HEAD)
error.h
Go to the documentation of this file.
1 #ifndef RBIMPL_ERROR_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ERROR_H
28 #include "ruby/internal/value.h"
29 
43 typedef enum {
46 
49 
52 
53  RB_WARN_CATEGORY_ALL_BITS = 0x6 /* no RB_WARN_CATEGORY_NONE bit */
55 
57 enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE};
59 #define RB_IO_WAIT_READABLE RB_IO_WAIT_READABLE
60 #define RB_IO_WAIT_WRITABLE RB_IO_WAIT_WRITABLE
64 
65 
72 VALUE rb_errinfo(void);
73 
84 void rb_set_errinfo(VALUE err);
85 
88 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
101 void rb_raise(VALUE exc, const char *fmt, ...);
102 
105 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
115 void rb_fatal(const char *fmt, ...);
116 
120 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
137 void rb_bug(const char *fmt, ...);
138 
149 void rb_bug_errno(const char *msg, int err);
150 
174 void rb_sys_fail(const char *msg);
175 
185 void rb_sys_fail_str(VALUE msg);
186 
202 void rb_mod_sys_fail(VALUE mod, const char *msg);
203 
214 void rb_mod_sys_fail_str(VALUE mod, VALUE msg);
215 
234 void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg);
235 
246 void rb_iter_break(void);
247 
285 void rb_iter_break_value(VALUE val);
286 
308 void rb_exit(int status);
309 
315 void rb_notimplement(void);
316 
324 VALUE rb_syserr_new(int err, const char * msg);
325 
334 VALUE rb_syserr_new_str(int n, VALUE arg);
335 
345 void rb_syserr_fail(int err, const char *msg);
346 
357 void rb_syserr_fail_str(int err, VALUE msg);
358 
371 void rb_mod_syserr_fail(VALUE mod, int err, const char *msg);
372 
384 void rb_mod_syserr_fail_str(VALUE mod, int err, VALUE msg);
385 
403 void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite waiting, int err, const char *msg);
404 
422 void rb_unexpected_type(VALUE self, int t);
423 
435 
446 VALUE *rb_ruby_debug_ptr(void);
447 
459 #define ruby_verbose (*rb_ruby_verbose_ptr())
460 
470 #define ruby_debug (*rb_ruby_debug_ptr())
471 
472 /* reports if `-W' specified */
474 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
494 void rb_warning(const char *fmt, ...);
495 
497 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
504 void rb_category_warning(rb_warning_category_t cat, const char *fmt, ...);
505 
506 RBIMPL_ATTR_NONNULL((1, 3))
507 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
517 void rb_compile_warning(const char *file, int line, const char *fmt, ...);
518 
520 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
528 void rb_sys_warning(const char *fmt, ...);
529 
530 /* reports always */
533 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
540 void rb_warn(const char *fmt, ...);
541 
544 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
552 void rb_category_warn(rb_warning_category_t cat, const char *fmt, ...);
553 
554 RBIMPL_ATTR_NONNULL((1, 3))
555 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
564 void rb_compile_warn(const char *file, int line, const char *fmt, ...);
565 
566 RBIMPL_ATTR_NONNULL((2, 4))
567 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 4, 5)
576 void rb_category_compile_warn(rb_warning_category_t cat, const char *file, int line, const char *fmt, ...);
577 
581 
582 #endif /* RBIMPL_ERROR_H */
Defines RBIMPL_ATTR_COLD.
#define RBIMPL_ATTR_COLD()
Wraps (or simulates) __attribute__((cold))
Definition: cold.h:32
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:106
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:97
Defines RBIMPL_ATTR_FORMAT.
#define RBIMPL_ATTR_FORMAT(x, y, z)
Wraps (or simulates) __attribute__((format))
Definition: format.h:27
void rb_notimplement(void)
Definition: error.c:3068
void rb_mod_sys_fail(VALUE mod, const char *mesg)
Identical to rb_sys_fail(), except it takes additional module to extend the exception object before r...
Definition: error.c:3204
rb_warning_category_t
Warning categories.
Definition: error.h:43
void rb_category_warn(rb_warning_category_t category, const char *fmt,...)
Identical to rb_category_warning(), except it reports always regardless of runtime -W flag.
Definition: error.c:428
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
Definition: error.c:3025
void rb_compile_warn(const char *file, int line, const char *fmt,...)
Identical to rb_compile_warning(), except it reports always regardless of runtime -W flag.
Definition: error.c:360
void rb_category_warning(rb_warning_category_t category, const char *fmt,...)
Identical to rb_warning(), except it takes additional "category" parameter.
Definition: error.c:460
void rb_mod_syserr_fail(VALUE mod, int e, const char *mesg)
Identical to rb_mod_sys_fail(), except it does not depend on C global variable errno.
Definition: error.c:3218
void rb_syserr_fail(int e, const char *mesg)
Raises appropriate exception that represents a C errno.
Definition: error.c:3137
void rb_bug(const char *fmt,...)
Interpreter panic switch.
Definition: error.c:802
void rb_iter_break(void)
Breaks from a block.
Definition: vm.c:1821
void rb_sys_fail(const char *mesg)
Converts a C errno into a Ruby exception, then raises it.
Definition: error.c:3149
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.
Definition: io.c:13496
void rb_sys_warning(const char *fmt,...)
Identical to rb_sys_fail(), except it does not raise an exception to render a warning instead.
Definition: error.c:3286
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.
Definition: error.c:3131
void rb_mod_syserr_fail_str(VALUE mod, int e, VALUE mesg)
Identical to rb_mod_syserr_fail(), except it takes the message in Ruby's String instead of C's.
Definition: error.c:3225
void rb_set_errinfo(VALUE err)
Sets the current exception ($!) to the given value.
Definition: eval.c:1764
void rb_syserr_fail_str(int e, VALUE mesg)
Identical to rb_syserr_fail(), except it takes the message in Ruby's String instead of C's.
Definition: error.c:3143
void rb_fatal(const char *fmt,...)
Raises the unsung "fatal" exception.
Definition: error.c:3076
void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg)
Raises appropriate exception using the parameters.
Definition: io.c:13490
void rb_iter_break_value(VALUE val)
Identical to rb_iter_break(), except it additionally takes the "value" of this breakage.
Definition: vm.c:1827
rb_io_wait_readwrite
for rb_readwrite_sys_fail first argument
Definition: error.h:57
void rb_category_compile_warn(rb_warning_category_t category, const char *file, int line, const char *fmt,...)
Identical to rb_compile_warn(), except it also accepts category.
Definition: error.c:389
void rb_warn(const char *fmt,...)
Identical to rb_warning(), except it reports always regardless of runtime -W flag.
Definition: error.c:418
void rb_bug_errno(const char *mesg, int errno_arg)
This is a wrapper of rb_bug() which automatically constructs appropriate message from the passed errn...
Definition: error.c:830
void rb_compile_warning(const char *file, int line, const char *fmt,...)
Issues a compile-time warning that happens at __file__:__line__.
Definition: error.c:375
VALUE * rb_ruby_debug_ptr(void)
This is an implementation detail of ruby_debug.
Definition: vm.c:3871
VALUE rb_errinfo(void)
This is the same as $! in Ruby.
Definition: eval.c:1758
VALUE * rb_ruby_verbose_ptr(void)
This is an implementation detail of ruby_verbose.
Definition: vm.c:3864
VALUE rb_syserr_new(int n, const char *mesg)
Creates an exception object that represents the given C errno.
Definition: error.c:3123
void rb_sys_fail_str(VALUE mesg)
Identical to rb_sys_fail(), except it takes the message in Ruby's String instead of C's.
Definition: error.c:3155
void rb_unexpected_type(VALUE x, int t)
Fails with the given object's type incompatibility to the type.
Definition: error.c:1029
void rb_mod_sys_fail_str(VALUE mod, VALUE mesg)
Identical to rb_mod_sys_fail(), except it takes the message in Ruby's String instead of C's.
Definition: error.c:3211
void rb_exit(int status)
Terminates the current execution context.
Definition: process.c:4471
void rb_warning(const char *fmt,...)
Issues a warning.
Definition: error.c:449
@ RB_WARN_CATEGORY_DEPRECATED
Warning is for deprecated features.
Definition: error.h:48
@ RB_WARN_CATEGORY_EXPERIMENTAL
Warning is for experimental features.
Definition: error.h:51
@ RB_WARN_CATEGORY_NONE
Category unspecified.
Definition: error.h:45
RBIMPL_ATTR_NORETURN() void rb_eof_error(void)
Utility function to raise rb_eEOFError.
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition: nonnull.h:27
Defines RBIMPL_ATTR_NORETURN.
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40