Feature #14141 » 0002-Add-Exception-display-to-log-exception.patch
NEWS | ||
---|---|---|
* Exception
|
||
* Exception#formatted [Feature #14141]
|
||
* Exception#display [Feature #14141]
|
||
* Dir
|
||
error.c | ||
---|---|---|
/*
|
||
* call-seq:
|
||
* exception.display(port=$stderr) -> nil
|
||
*
|
||
* Prints formatted <i>exception</i> on the given port (default to <code>$stderr</code>).
|
||
* Format includes backtrace, exception class and exception message.
|
||
*
|
||
* This method is useful to log caught exceptions.
|
||
*
|
||
* begin
|
||
* some_work
|
||
* rescue => e
|
||
* e.display
|
||
* retry
|
||
* end
|
||
*/
|
||
static VALUE
|
||
exc_display(int argc, VALUE *argv, VALUE exc)
|
||
{
|
||
VALUE str = rb_str_new2("");
|
||
VALUE out;
|
||
if (argc == 0) {
|
||
out = rb_stderr;
|
||
}
|
||
else {
|
||
rb_scan_args(argc, argv, "01", &out);
|
||
}
|
||
rb_ec_error_write(exc, Qundef, str);
|
||
rb_io_write(out, str);
|
||
return Qnil;
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* exception.message -> string
|
||
*
|
||
* Returns the result of invoking <code>exception.to_s</code>.
|
||
... | ... | |
rb_define_method(rb_eException, "==", exc_equal, 1);
|
||
rb_define_method(rb_eException, "to_s", exc_to_s, 0);
|
||
rb_define_method(rb_eException, "formatted", exc_formatted, 0);
|
||
rb_define_method(rb_eException, "display", exc_display, -1);
|
||
rb_define_method(rb_eException, "message", exc_message, 0);
|
||
rb_define_method(rb_eException, "inspect", exc_inspect, 0);
|
- « Previous
- 1
- 2
- 3
- Next »