Ruby: include/ruby/internal/error.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

error.h
Go to the documentation of this file.
1#ifndef RBIMPL_ERROR_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ERROR_H
23#include "ruby/internal/attr/cold.h"
24#include "ruby/internal/attr/format.h"
25#include "ruby/internal/attr/noreturn.h"
26#include "ruby/internal/attr/nonnull.h"
27#include "ruby/internal/dllexport.h"
28#include "ruby/internal/value.h"
29
43 typedef enum {
45 RB_WARN_CATEGORY_NONE,
46
48 RB_WARN_CATEGORY_DEPRECATED,
49
51 RB_WARN_CATEGORY_EXPERIMENTAL,
52
53 RB_WARN_CATEGORY_ALL_BITS = 0x6 /* no RB_WARN_CATEGORY_NONE bit */
54} rb_warning_category_t;
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
63 RBIMPL_SYMBOL_EXPORT_BEGIN()
64
65
72 VALUE rb_errinfo(void);
73
84void rb_set_errinfo(VALUE err);
85
86 RBIMPL_ATTR_NORETURN()
87 RBIMPL_ATTR_NONNULL((2))
88 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
101void rb_raise(VALUE exc, const char *fmt, ...);
102
103 RBIMPL_ATTR_NORETURN()
104 RBIMPL_ATTR_NONNULL((1))
105 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
115void rb_fatal(const char *fmt, ...);
116
117 RBIMPL_ATTR_COLD()
118 RBIMPL_ATTR_NORETURN()
119 RBIMPL_ATTR_NONNULL((1))
120 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
137void rb_bug(const char *fmt, ...);
138
139 RBIMPL_ATTR_NORETURN()
140 RBIMPL_ATTR_NONNULL(())
149void rb_bug_errno(const char *msg, int err);
150
151 RBIMPL_ATTR_NORETURN()
174void rb_sys_fail(const char *msg);
175
176 RBIMPL_ATTR_NORETURN()
185void rb_sys_fail_str(VALUE msg);
186
187 RBIMPL_ATTR_NORETURN()
188 RBIMPL_ATTR_NONNULL((2))
202void rb_mod_sys_fail(VALUE mod, const char *msg);
203
204 RBIMPL_ATTR_NORETURN()
214void rb_mod_sys_fail_str(VALUE mod, VALUE msg);
215
216 RBIMPL_ATTR_NORETURN()
234void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg);
235
236 RBIMPL_ATTR_NORETURN()
246void rb_iter_break(void);
247
248 RBIMPL_ATTR_NORETURN()
285void rb_iter_break_value(VALUE val);
286
287 RBIMPL_ATTR_NORETURN()
308void rb_exit(int status);
309
310 RBIMPL_ATTR_NORETURN()
315void 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
336 RBIMPL_ATTR_NORETURN()
345void rb_syserr_fail(int err, const char *msg);
346
347 RBIMPL_ATTR_NORETURN()
357void rb_syserr_fail_str(int err, VALUE msg);
358
359 RBIMPL_ATTR_NORETURN()
360 RBIMPL_ATTR_NONNULL(())
371void rb_mod_syserr_fail(VALUE mod, int err, const char *msg);
372
373 RBIMPL_ATTR_NORETURN()
384void rb_mod_syserr_fail_str(VALUE mod, int err, VALUE msg);
385
386 RBIMPL_ATTR_NORETURN()
403void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite waiting, int err, const char *msg);
404
405 RBIMPL_ATTR_COLD()
406 RBIMPL_ATTR_NORETURN()
422void rb_unexpected_type(VALUE self, int t);
423
434 VALUE *rb_ruby_verbose_ptr(void);
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 */
473 RBIMPL_ATTR_NONNULL((1))
474 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
494void rb_warning(const char *fmt, ...);
495
496 RBIMPL_ATTR_NONNULL((2))
497 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
504void 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)
517void rb_compile_warning(const char *file, int line, const char *fmt, ...);
518
519 RBIMPL_ATTR_NONNULL((1))
520 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
528void rb_sys_warning(const char *fmt, ...);
529
530/* reports always */
531 RBIMPL_ATTR_COLD()
532 RBIMPL_ATTR_NONNULL((1))
533 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
540void rb_warn(const char *fmt, ...);
541
542 RBIMPL_ATTR_COLD()
543 RBIMPL_ATTR_NONNULL((2))
544 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
552void 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)
564void 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)
576void rb_category_compile_warn(rb_warning_category_t cat, const char *file, int line, const char *fmt, ...);
577
580 RBIMPL_SYMBOL_EXPORT_END()
581
582#endif /* RBIMPL_ERROR_H */
cold.h
Defines RBIMPL_ATTR_COLD.
RBIMPL_ATTR_COLD
#define RBIMPL_ATTR_COLD()
Wraps (or simulates) __attribute__((cold))
Definition cold.h:34
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
format.h
Defines RBIMPL_ATTR_FORMAT.
RBIMPL_ATTR_FORMAT
#define RBIMPL_ATTR_FORMAT(x, y, z)
Wraps (or simulates) __attribute__((format))
Definition format.h:29
rb_notimplement
void rb_notimplement(void)
Definition error.c:3193
rb_mod_sys_fail
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:3329
rb_warning_category_t
rb_warning_category_t
Warning categories.
Definition error.h:43
rb_category_warn
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:421
rb_raise
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
Definition error.c:3150
rb_compile_warn
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:363
rb_category_warning
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:453
rb_mod_syserr_fail
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:3343
rb_syserr_fail
void rb_syserr_fail(int e, const char *mesg)
Raises appropriate exception that represents a C errno.
Definition error.c:3262
rb_bug
void rb_bug(const char *fmt,...)
Interpreter panic switch.
Definition error.c:794
rb_iter_break
void rb_iter_break(void)
Breaks from a block.
Definition vm.c:1901
rb_sys_fail
void rb_sys_fail(const char *mesg)
Converts a C errno into a Ruby exception, then raises it.
Definition error.c:3274
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.
Definition io.c:14576
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.
Definition error.c:3411
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.
Definition error.c:3256
rb_mod_syserr_fail_str
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:3350
rb_set_errinfo
void rb_set_errinfo(VALUE err)
Sets the current exception ($!) to the given value.
Definition eval.c:1884
rb_syserr_fail_str
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:3268
rb_fatal
void rb_fatal(const char *fmt,...)
Raises the unsung "fatal" exception.
Definition error.c:3201
rb_readwrite_sys_fail
void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg)
Raises appropriate exception using the parameters.
Definition io.c:14570
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.
Definition vm.c:1907
rb_io_wait_readwrite
rb_io_wait_readwrite
for rb_readwrite_sys_fail first argument
Definition error.h:57
rb_category_compile_warn
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:384
rb_warn
void rb_warn(const char *fmt,...)
Identical to rb_warning(), except it reports always regardless of runtime -W flag.
Definition error.c:411
rb_bug_errno
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:822
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__.
Definition error.c:374
rb_errinfo
VALUE rb_errinfo(void)
This is the same as $! in Ruby.
Definition eval.c:1878
rb_syserr_new
VALUE rb_syserr_new(int n, const char *mesg)
Creates an exception object that represents the given C errno.
Definition error.c:3248
rb_sys_fail_str
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:3280
rb_unexpected_type
void rb_unexpected_type(VALUE x, int t)
Fails with the given object's type incompatibility to the type.
Definition error.c:1021
rb_mod_sys_fail_str
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:3336
rb_exit
void rb_exit(int status)
Terminates the current execution context.
Definition process.c:4519
rb_warning
void rb_warning(const char *fmt,...)
Issues a warning.
Definition error.c:442
RB_WARN_CATEGORY_DEPRECATED
@ RB_WARN_CATEGORY_DEPRECATED
Warning is for deprecated features.
Definition error.h:48
RB_WARN_CATEGORY_EXPERIMENTAL
@ RB_WARN_CATEGORY_EXPERIMENTAL
Warning is for experimental features.
Definition error.h:51
RB_WARN_CATEGORY_NONE
@ RB_WARN_CATEGORY_NONE
Category unspecified.
Definition error.h:45
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
noreturn.h
Defines RBIMPL_ATTR_NORETURN.
RBIMPL_ATTR_NORETURN
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40