From 01f96ee6197a7b5a2c64353a3b38260994ce5ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 16 Nov 2017 06:10:12 +0100 Subject: Add documentation for the new stacktrace syntax --- erts/doc/src/erlang.xml | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erlang.xml b/erts/doc/src/erlang.xml index daf3002ec7..d7404fa3ce 100644 --- a/erts/doc/src/erlang.xml +++ b/erts/doc/src/erlang.xml @@ -1985,39 +1985,26 @@ true Get the call stack back-trace of the last exception. -

Gets the call stack back-trace (stacktrace) for an - exception that has just been caught - in the calling process as a list of - {Module,Function,Arity,Location} - tuples. Field Arity in the first tuple can be the - argument list of that function call instead of an arity integer, - depending on the exception.

-

If there has not been any exceptions in a process, the - stacktrace is []. After a code change for the process, - the stacktrace can also be reset to [].

-

erlang:get_stacktrace/0 is only guaranteed to return - a stacktrace if called (directly or indirectly) from within the - scope of a try expression. That is, the following call works:

+

erlang:get_stacktrace/0 is deprecated and will stop working + in a future release.

+

Instead of using erlang:get_stacktrace/0 to retrieve + the call stack back-trace, use the following syntax:

 try Expr
 catch
-  C:R ->
-   {C,R,erlang:get_stacktrace()}
+  Class:Reason:Stacktrace ->
+   {Class,Reason,Stacktrace}
 end
-

As does this call:

-
-try Expr
-catch
-  C:R ->
-   {C,R,helper()}
-end
-
-helper() ->
-  erlang:get_stacktrace().
- -

In a future release, - erlang:get_stacktrace/0 will return [] if called - from outside a try expression.

+

erlang:get_stacktrace/0 retrieves the call stack back-trace + (stacktrace) for an exception that has just been + caught in the calling process as a list of + {Module,Function,Arity,Location} + tuples. Field Arity in the first tuple can + be the argument list of that function call instead of an arity + integer, depending on the exception.

+

If there has not been any exceptions in a process, the + stacktrace is []. After a code change for the process, + the stacktrace can also be reset to [].

The stacktrace is the same data as operator catch returns, for example:

-- 
cgit v1.2.3