diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2022-09-23 16:40:59 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2022-09-23 16:40:59 +0900 |
commit | a78c733cc32cc3da3796cbf65da21cdd40c63230 (patch) | |
tree | f76c3eeafe0dc6adb9be1e21da8c40bf617381bb /error.c | |
parent | 6e46bf1e54e7fe83dc80e49394d980b71321b6f0 (diff) |
Revert "Revert "error.c: Let Exception#inspect inspect its message""
This reverts commit b9f030954a8a1572032f3548b39c5b8ac35792ce.
[Bug #18170]
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -34,6 +34,7 @@ #include "internal/io.h" #include "internal/load.h" #include "internal/object.h" +#include "internal/string.h" #include "internal/symbol.h" #include "internal/thread.h" #include "internal/variable.h" @@ -1439,8 +1440,15 @@ exc_inspect(VALUE exc) str = rb_str_buf_new2("#<"); klass = rb_class_name(klass); rb_str_buf_append(str, klass); - rb_str_buf_cat(str, ": ", 2); - rb_str_buf_append(str, exc); + + if (RTEST(rb_str_include(exc, rb_str_new2("\n")))) { + rb_str_catf(str, ":%+"PRIsVALUE, exc); + } + else { + rb_str_buf_cat(str, ": ", 2); + rb_str_buf_append(str, exc); + } + rb_str_buf_cat(str, ">", 1); return str; |