123456789_123456789_123456789_123456789_123456789_

Module: Warning

Relationships & Source Files
Namespace Children
Classes:
Defined in: error.c

Overview

The Warning module contains a single method named #warn, and the module extends itself, making #warn available. #warn is called for all warnings issued by Ruby. By default, warnings are printed to $stderr.

By overriding #warn, you can change how warnings are handled by Ruby, either filtering some warnings, and/or outputting warnings somewhere other than $stderr. When #warn is overridden, super can be called to get the default behavior of printing the warning to $stderr.

Instance Method Summary

  • #warn(msg) ⇒ nil

    Writes warning message msg to $stderr, followed by a newline if the message does not end in a newline.

Instance Method Details

#warn(msg) ⇒ nil

Writes warning message msg to $stderr, followed by a newline if the message does not end in a newline. This method is called by Ruby for all emitted warnings.

[ GitHub ]

  
# File 'error.c', line 154

static VALUE
rb_warning_s_warn(VALUE mod, VALUE str)
{
    Check_Type(str, T_STRING);
    rb_must_asciicompat(str);
    rb_write_error_str(str);
    return Qnil;
}