diff options
author | zverok <zverok.offline@gmail.com> | 2021-12-20 09:07:25 +0200 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2021-12-20 08:56:03 -0800 |
commit | 81f08edbd6f1d7c9ebd39dbe6766cde59173e75a (patch) | |
tree | 543d372aacaabc14bfcaa9a3094a47bb0ed5a76b | |
parent | 37aea9d7984d9bf884df121ab0b44168ae1ac0c5 (diff) | |
download | ruby-81f08edbd6f1d7c9ebd39dbe6766cde59173e75a.tar.gz |
[DOC] Document Thread::Backtrace.limit
-rw-r--r-- | vm_backtrace.c | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/vm_backtrace.c b/vm_backtrace.c index 02c2ff4abd..9f5fcc8da2 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -782,6 +782,56 @@ backtrace_load_data(VALUE self, VALUE str) return self; } +/* + * call-seq: Threade::Backtrace::limit -> integer + * + * Returns maximum backtrace length set by <tt>--backtrace-limit</tt> + * command-line option. The defalt is <tt>-1</tt> which means unlimited + * backtraces. If the value is zero or positive, the error backtraces, + * produced by Exception#full_message, are abbreviated and the extra lines + * are replaced by <tt>... 3 levels... </tt> + * + * $ ruby -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" + * - 1 + * .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) + * from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' + * from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' + * from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' + * from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' + * from .../lib/ruby/3.1.0/net/http.rb:965:in `start' + * from .../lib/ruby/3.1.0/net/http.rb:627:in `start' + * from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' + * from .../lib/ruby/3.1.0/net/http.rb:474:in `get' + * .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) + * from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' + * from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' + * from .../lib/ruby/3.1.0/net/http.rb:998:in `connect' + * from .../lib/ruby/3.1.0/net/http.rb:976:in `do_start' + * from .../lib/ruby/3.1.0/net/http.rb:965:in `start' + * from .../lib/ruby/3.1.0/net/http.rb:627:in `start' + * from .../lib/ruby/3.1.0/net/http.rb:503:in `get_response' + * from .../lib/ruby/3.1.0/net/http.rb:474:in `get' + * from -e:1:in `<main>' + * + * $ ruby --backtrace-limit 2 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" + * 2 + * .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) + * from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' + * from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' + * ... 7 levels... + * .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) + * from .../lib/ruby/3.1.0/socket.rb:227:in `foreach' + * from .../lib/ruby/3.1.0/socket.rb:632:in `tcp' + * ... 7 levels... + * + * $ ruby --backtrace-limit 0 -r net/http -e "p Thread::Backtrace.limit; Net::HTTP.get(URI('http://wrong.address'))" + * 0 + * .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': Failed to open TCP connection to wrong.address:80 (getaddrinfo: Name or service not known) (SocketError) + * ... 9 levels... + * .../lib/ruby/3.1.0/socket.rb:227:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError) + * ... 9 levels... + * + */ static VALUE backtrace_limit(VALUE self) { @@ -1194,7 +1244,11 @@ rb_f_caller_locations(int argc, VALUE *argv, VALUE _) void Init_vm_backtrace(void) { - /* :nodoc: */ + /* + * An internal representation of the backtrace. The user will never interact with + * objects of this class directly, but class methods can be used to get backtrace + * settings of the current session. + */ rb_cBacktrace = rb_define_class_under(rb_cThread, "Backtrace", rb_cObject); rb_define_alloc_func(rb_cBacktrace, backtrace_alloc); rb_undef_method(CLASS_OF(rb_cBacktrace), "new"); |