本文简要介绍ruby语言中 Thread::Backtrace.Threade::Backtrace::limit
的用法。
用法
Threade::Backtrace::limit → integer
返回由 --backtrace-limit
命令行选项设置的最大回溯长度。默认值是-1
,这意味着无限的回溯。如果该值为零或正数,则 Exception#full_message
生成的错误回溯将被缩写,并且多余的行将被 ... 3 levels...
替换
$ 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...
相关用法
- Ruby Time tv_sec用法及代码示例
- Ruby MatchData.pre_match用法及代码示例
- Ruby Symbol capitalize用法及代码示例
- Ruby Matrix lup()用法及代码示例
- Ruby SizedQueue clear()用法及代码示例
- Ruby Object.instance_variable_get用法及代码示例
- Ruby Spotter.spot_op_asgn2_for_name用法及代码示例
- Ruby Float arg()用法及代码示例
- Ruby WIN32OLE_METHOD#visible?用法及代码示例
- Ruby Matrix unitary?()用法及代码示例
- Ruby Integer.nobits?用法及代码示例
- Ruby Kernel.local_variables用法及代码示例
- Ruby StringScanner skip_until用法及代码示例
- Ruby StringScanner search_full用法及代码示例
- Ruby Matrix symmetric?()用法及代码示例
- Ruby CStructEntity.[]=用法及代码示例
- Ruby BigMath.cos用法及代码示例
- Ruby Vertex.==用法及代码示例
- Ruby Array.push用法及代码示例
- Ruby Date.valid_civil?用法及代码示例
- Ruby Generator模块用法及代码示例
- Ruby Array.hash用法及代码示例
- Ruby Hash.reject用法及代码示例
- Ruby ARGF.path用法及代码示例
- Ruby String.match?用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 limit。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。