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

Ruby 3.3.4p94 (2024-07-09 revision be1089c8ec5ba40e09b1553e36b3174bf4014d9d)

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
54 RB_WARN_CATEGORY_PERFORMANCE,
55
56 RB_WARN_CATEGORY_DEFAULT_BITS = (
57 (1U << RB_WARN_CATEGORY_DEPRECATED) |
58 (1U << RB_WARN_CATEGORY_EXPERIMENTAL) |
59 0),
60
61 RB_WARN_CATEGORY_ALL_BITS = (
62 (1U << RB_WARN_CATEGORY_DEPRECATED) |
63 (1U << RB_WARN_CATEGORY_EXPERIMENTAL) |
64 (1U << RB_WARN_CATEGORY_PERFORMANCE) |
65 0)
66} rb_warning_category_t;
67
69 enum rb_io_wait_readwrite {RB_IO_WAIT_READABLE, RB_IO_WAIT_WRITABLE};
71#define RB_IO_WAIT_READABLE RB_IO_WAIT_READABLE
72#define RB_IO_WAIT_WRITABLE RB_IO_WAIT_WRITABLE
75 RBIMPL_SYMBOL_EXPORT_BEGIN()
76
77
84 VALUE rb_errinfo(void);
85
96void rb_set_errinfo(VALUE err);
97
98 RBIMPL_ATTR_NORETURN()
99 RBIMPL_ATTR_NONNULL((2))
100 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
113void rb_raise(VALUE exc, const char *fmt, ...);
114
115 RBIMPL_ATTR_NORETURN()
116 RBIMPL_ATTR_NONNULL((1))
117 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
127void rb_fatal(const char *fmt, ...);
128
129 RBIMPL_ATTR_COLD()
130 RBIMPL_ATTR_NORETURN()
131 RBIMPL_ATTR_NONNULL((1))
132 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
149void rb_bug(const char *fmt, ...);
150
151 RBIMPL_ATTR_NORETURN()
152 RBIMPL_ATTR_NONNULL(())
161void rb_bug_errno(const char *msg, int err);
162
163 RBIMPL_ATTR_NORETURN()
186void rb_sys_fail(const char *msg);
187
188 RBIMPL_ATTR_NORETURN()
197void rb_sys_fail_str(VALUE msg);
198
199 RBIMPL_ATTR_NORETURN()
200 RBIMPL_ATTR_NONNULL((2))
214void rb_mod_sys_fail(VALUE mod, const char *msg);
215
216 RBIMPL_ATTR_NORETURN()
226void rb_mod_sys_fail_str(VALUE mod, VALUE msg);
227
228 RBIMPL_ATTR_NORETURN()
246void rb_readwrite_sys_fail(enum rb_io_wait_readwrite waiting, const char *msg);
247
248 RBIMPL_ATTR_NORETURN()
258void rb_iter_break(void);
259
260 RBIMPL_ATTR_NORETURN()
297void rb_iter_break_value(VALUE val);
298
299 RBIMPL_ATTR_NORETURN()
320void rb_exit(int status);
321
322 RBIMPL_ATTR_NORETURN()
327void rb_notimplement(void);
328
336 VALUE rb_syserr_new(int err, const char * msg);
337
346 VALUE rb_syserr_new_str(int n, VALUE arg);
347
348 RBIMPL_ATTR_NORETURN()
357void rb_syserr_fail(int err, const char *msg);
358
359 RBIMPL_ATTR_NORETURN()
369void rb_syserr_fail_str(int err, VALUE msg);
370
371 RBIMPL_ATTR_NORETURN()
372 RBIMPL_ATTR_NONNULL(())
383void rb_mod_syserr_fail(VALUE mod, int err, const char *msg);
384
385 RBIMPL_ATTR_NORETURN()
396void rb_mod_syserr_fail_str(VALUE mod, int err, VALUE msg);
397
398 RBIMPL_ATTR_NORETURN()
415void rb_readwrite_syserr_fail(enum rb_io_wait_readwrite waiting, int err, const char *msg);
416
417 RBIMPL_ATTR_COLD()
418 RBIMPL_ATTR_NORETURN()
434void rb_unexpected_type(VALUE self, int t);
435
446 VALUE *rb_ruby_verbose_ptr(void);
447
458 VALUE *rb_ruby_debug_ptr(void);
459
471#define ruby_verbose (*rb_ruby_verbose_ptr())
472
482#define ruby_debug (*rb_ruby_debug_ptr())
483
484/* reports if $VERBOSE is true */
485 RBIMPL_ATTR_NONNULL((1))
486 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
507void rb_warning(const char *fmt, ...);
508
509 RBIMPL_ATTR_NONNULL((2))
510 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
517void rb_category_warning(rb_warning_category_t cat, const char *fmt, ...);
518
519 RBIMPL_ATTR_NONNULL((1, 3))
520 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
530void rb_compile_warning(const char *file, int line, const char *fmt, ...);
531
532 RBIMPL_ATTR_NONNULL((1))
533 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
541void rb_sys_warning(const char *fmt, ...);
542
543/* reports if $VERBOSE is not nil (so if it is true or false) */
544 RBIMPL_ATTR_COLD()
545 RBIMPL_ATTR_NONNULL((1))
546 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
554void rb_warn(const char *fmt, ...);
555
556 RBIMPL_ATTR_COLD()
557 RBIMPL_ATTR_NONNULL((2))
558 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
565void rb_category_warn(rb_warning_category_t cat, const char *fmt, ...);
566
567 RBIMPL_ATTR_NONNULL((1, 3))
568 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
576void rb_compile_warn(const char *file, int line, const char *fmt, ...);
577
578 RBIMPL_ATTR_NONNULL((2, 4))
579 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 4, 5)
588void rb_category_compile_warn(rb_warning_category_t cat, const char *file, int line, const char *fmt, ...);
589
592 RBIMPL_SYMBOL_EXPORT_END()
593
594#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:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
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:3498
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:3636
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 unless $VERBOSE is nil.
Definition error.c:433
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:465
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:3650
rb_syserr_fail
void rb_syserr_fail(int e, const char *mesg)
Raises appropriate exception that represents a C errno.
Definition error.c:3567
rb_iter_break
void rb_iter_break(void)
Breaks from a block.
Definition vm.c:2043
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:14577
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:3718
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:3561
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:3657
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:3573
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:14571
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:2049
rb_io_wait_readwrite
rb_io_wait_readwrite
for rb_readwrite_sys_fail first argument
Definition error.h:69
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:396
rb_warn
void rb_warn(const char *fmt,...)
Identical to rb_warning(), except it reports unless $VERBOSE is nil.
Definition error.c:423
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:1075
rb_errinfo
VALUE rb_errinfo(void)
This is the same as $! in Ruby.
Definition eval.c:1898
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:3553
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:1274
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:3643
rb_exit
void rb_exit(int status)
Terminates the current execution context.
Definition process.c:4454
rb_warning
void rb_warning(const char *fmt,...)
Issues a warning.
Definition error.c:454
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_PERFORMANCE
@ RB_WARN_CATEGORY_PERFORMANCE
Warning is for performance issues (not enabled by -w).
Definition error.h:54
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