Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法将一组Thread::Backtrace::Location实例附加到一个Exception实例上?如果是这样,怎么做?有Kernel#caller_locationsand Thread#backtrace_locations,但它们与当前上下文或线程有关,与任意异常实例无关。不知道会不会用到。
Thread::Backtrace::Location
Exception
Kernel#caller_locations
Thread#backtrace_locations
是的,从 ruby v2.1 开始就有可能,尽管在 v2.2 中可能会准备好完全支持
方法:https ://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/44170/diff/error.c
讨论:https ://bugs.ruby-lang.org/issues/8960