instance method
Warning#warn
(::String message, ?category: ::Warning::category?) -> nil
warn(msg, category: nil) → nil
error.c
View on GitHub ↗
static VALUE
rb_warning_s_warn(int argc, VALUE *argv, VALUE mod)
{
VALUE str;
VALUE opt;
VALUE category = Qnil;
rb_scan_args(argc, argv, "1:", &str, &opt);
if (!NIL_P(opt)) rb_get_kwargs(opt, &id_category, 0, 1, &category);
Check_Type(str, T_STRING);
rb_must_asciicompat(str);
if (!NIL_P(category)) {
rb_warning_category_t cat = rb_warning_category_from_name(category);
if (!rb_warning_category_enabled_p(cat)) return Qnil;
}
rb_write_error_str(str);
return Qnil;
}
Writes warning message msg to $stderr. This method is called by Ruby for all emitted warnings. A category may be included with the warning.
See the documentation of the Warning module for how to customize this.
Ruby version changes
-
3.0
-
Warning#warnnow supports a category keyword argument. [Feature #17122]
-