84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
现在有一个测试代码: def study_ruby_exception arg_1 begin puts 10/arg_1 rescue Exception => e puts e.message end end study_ruby_exception 0 当我运行的时候会打印输出:pided by 0 除数为零异常 我想得到这个异常的所有堆栈消息。例如:接防执行这个代码的时候是怎么的调用关系。错在哪个文件的哪 个方法里面等! 我应该怎么输出呢?
认证高级PHP讲师
Exception class has a backtrace method that returns an array containing a stack...
Reference code...
def study_ruby_exception arg_1 begin puts 10/arg_1 rescue Exception => e puts e.backtrace end end study_ruby_exception 0
A few words by the way...rescue actually does not have to appear together with begin...
Your example can actually be written like this...
def study_ruby_exception arg_1 puts 10/arg_1 rescue Exception => e puts e.backtrace end study_ruby_exception 0
Exception class has a backtrace method that returns an array containing a stack...
Reference code...
A few words by the way...rescue actually does not have to appear together with begin...
Your example can actually be written like this...