抓取它后,如何在erlang中写入一个异常堆栈跟踪? [英] How can I write an exception stack trace in erlang after catching it?

查看:235
本文介绍了抓取它后,如何在erlang中写入一个异常堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有这样的东西:

  try code_that_fails()
catch _:_ - > .....

如何在catch块中打印stacktrace?该块捕获所有异常,但我不知道如何打印堆栈...



你能帮助我吗?

解决方案

请参阅 get_stacktrace / 0 ,它允许您在调用过程中获取最后一个异常的堆栈跟踪。

  try 
code_that_fails()
catch
_:_ - >
erlang:display(erlang:get_stacktrace())
end


Suppose I have something like this :

try code_that_fails()
catch _:_ -> .....

How do I print the stacktrace in the catch block? That block catches all exceptions, but I don't know how to print the stack...

Can you help me?

解决方案

See get_stacktrace/0 which allow you to get the stacktrace of the last exception in the calling process.

try
   code_that_fails()
catch
   _:_ ->
      erlang:display(erlang:get_stacktrace())
end

这篇关于抓取它后,如何在erlang中写入一个异常堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆