Ruby  3.4.0dev (2024-11-22 revision 37a72b0150ec36b4ea27175039afc28c62207b0c)
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 
55 
58 
59  RB_WARN_CATEGORY_DEFAULT_BITS = (
62  0),
63 
64  RB_WARN_CATEGORY_ALL_BITS = (
69  0)
71 
73 enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE};
75 #define RB_IO_WAIT_READABLE RB_IO_WAIT_READABLE
76 #define RB_IO_WAIT_WRITABLE RB_IO_WAIT_WRITABLE
80 
81 
88 VALUE rb_errinfo(void);
89 
100 void rb_set_errinfo(VALUE err);
101 
104 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
117 void rb_raise(VALUE exc, const char *fmt, ...);
118 
121 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
131 void rb_fatal(const char *fmt, ...);
132 
136 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
153 void rb_bug(const char *fmt, ...);
154 
165 void rb_bug_errno(const char *msg, int err);
166 
190 void rb_sys_fail(const char *msg);
191 
201 void rb_sys_fail_str(VALUE msg);
202 
218 void rb_mod_sys_fail(VALUE mod, const char *msg);
219 
230 void rb_mod_sys_fail_str(VALUE mod, VALUE msg);
231 
250 void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg);
251 
262 void rb_iter_break(void);
263 
301 void rb_iter_break_value(VALUE val);
302 
324 void rb_exit(int status);
325 
331 void rb_notimplement(void);
332 
340 VALUE rb_syserr_new(int err, const char * msg);
341 
350 VALUE rb_syserr_new_str(int n, VALUE arg);
351 
361 void rb_syserr_fail(int err, const char *msg);
362 
373 void rb_syserr_fail_str(int err, VALUE msg);
374 
387 void rb_mod_syserr_fail(VALUE mod, int err, const char *msg);
388 
400 void rb_mod_syserr_fail_str(VALUE mod, int err, VALUE msg);
401 
419 void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite waiting, int err, const char *msg);
420 
438 void rb_unexpected_type(VALUE self, int t);
439 
451 
462 VALUE *rb_ruby_debug_ptr(void);
463 
475 #define ruby_verbose (*rb_ruby_verbose_ptr())
476 
486 #define ruby_debug (*rb_ruby_debug_ptr())
487 
488 /* reports if $VERBOSE is true */
490 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
511 void rb_warning(const char *fmt, ...);
512 
514 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
521 void rb_category_warning(rb_warning_category_t cat, const char *fmt, ...);
522 
523 RBIMPL_ATTR_NONNULL((1, 3))
524 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
534 void rb_compile_warning(const char *file, int line, const char *fmt, ...);
535 
537 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
545 void rb_sys_warning(const char *fmt, ...);
546 
547 /* reports if $VERBOSE is not nil (so if it is true or false) */
550 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
558 void rb_warn(const char *fmt, ...);
559 
562 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
569 void rb_category_warn(rb_warning_category_t cat, const char *fmt, ...);
570 
571 RBIMPL_ATTR_NONNULL((1, 3))
572 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
580 void rb_compile_warn(const char *file, int line, const char *fmt, ...);
581 
582 RBIMPL_ATTR_NONNULL((2, 4))
583 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 4, 5)
592 void rb_category_compile_warn(rb_warning_category_t cat, const char *file, int line, const char *fmt, ...);
593 
597 
598 #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:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
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:3678
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:3816
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 unless $VERBOSE is nil.
Definition: error.c:476
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
Definition: error.c:3635
void rb_compile_warn(const char *file, int line, const char *fmt,...)
Identical to rb_compile_warning(), except it reports unless $VERBOSE is nil.
Definition: error.c:397
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:508
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:3830
void rb_syserr_fail(int e, const char *mesg)
Raises appropriate exception that represents a C errno.
Definition: error.c:3747
void rb_bug(const char *fmt,...)
Interpreter panic switch.
Definition: error.c:1089
void rb_iter_break(void)
Breaks from a block.
Definition: vm.c:2075
void rb_sys_fail(const char *mesg)
Converts a C errno into a Ruby exception, then raises it.
Definition: error.c:3760
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:14626
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:3898
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:3741
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:3837
void rb_set_errinfo(VALUE err)
Sets the current exception ($!) to the given value.
Definition: eval.c:1926
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:3753
void rb_fatal(const char *fmt,...)
Raises the unsung "fatal" exception.
Definition: error.c:3686
void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg)
Raises appropriate exception using the parameters.
Definition: io.c:14620
void rb_iter_break_value(VALUE val)
Identical to rb_iter_break(), except it additionally takes the "value" of this breakage.
Definition: vm.c:2081
rb_io_wait_readwrite
for rb_readwrite_sys_fail first argument
Definition: error.h:73
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:439
void rb_warn(const char *fmt,...)
Identical to rb_warning(), except it reports unless $VERBOSE is nil.
Definition: error.c:466
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:1118
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:418
VALUE * rb_ruby_debug_ptr(void)
This is an implementation detail of ruby_debug.
Definition: vm.c:4493
VALUE rb_errinfo(void)
This is the same as $! in Ruby.
Definition: eval.c:1920
VALUE * rb_ruby_verbose_ptr(void)
This is an implementation detail of ruby_verbose.
Definition: vm.c:4486
VALUE rb_syserr_new(int n, const char *mesg)
Creates an exception object that represents the given C errno.
Definition: error.c:3733
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:3767
void rb_unexpected_type(VALUE x, int t)
Fails with the given object's type incompatibility to the type.
Definition: error.c:1338
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:3823
void rb_exit(int status)
Terminates the current execution context.
Definition: process.c:4451
void rb_warning(const char *fmt,...)
Issues a warning.
Definition: error.c:497
@ RB_WARN_CATEGORY_STRICT_UNUSED_BLOCK
Warning is for checking unused block strictly.
Definition: error.h:57
@ 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_PERFORMANCE
Warning is for performance issues (not enabled by -w).
Definition: error.h:54
@ 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