From 798f09de48b1a7abe43d54d6fa0377ad15c3f6aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?=
Date: Fri, 3 Jun 2016 12:13:09 +0200
Subject: Propagate exceptions fully when using proc_lib
This makes proc_lib behaves like a normal process as far
as the propagation of exceptions is concerned.
Before this commit, the following difference could be
observed:
6> spawn_link(fun() -> ssl:send(a,b) end).
<0.43.0>
7> flush().
Shell got {'EXIT',<0.43.0>,
{function_clause,
[{ssl,send,[a,b],[{file,"..."},{line,275}]}]}}
ok
8> proc_lib:spawn_link(fun() -> ssl:send(a,b) end).
<0.46.0>
9> flush().
Shell got {'EXIT',<0.46.0>,function_clause}
After this commit, we get the following instead:
3> flush().
Shell got {'EXIT',<0.61.0>,
{function_clause,
[{ssl,send,[a,b],[{file,"..."},{line,275}]},
{proc_lib,init_p,3,[{file,"..."},{line,232}]}]}}
The stacktrace will show minor differences of course
but the form is now the same as without proc_lib.
The rationale behind this commit is that:
* We now have a single form regardless of how the process
was started
* We can use the stacktrace to programmatically alter behavior
(for example an HTTP server identifying problems in input
decoding to send back a generic 400, or a 500 otherwise)
* We can access the stacktrace to print it somewhere (for
example an HTTP server could send it back to the client
when a debug mode is enabled)
---
lib/stdlib/doc/src/proc_lib.xml | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'lib/stdlib/doc/src/proc_lib.xml')
diff --git a/lib/stdlib/doc/src/proc_lib.xml b/lib/stdlib/doc/src/proc_lib.xml
index da03c39a26..e64b2ce18a 100644
--- a/lib/stdlib/doc/src/proc_lib.xml
+++ b/lib/stdlib/doc/src/proc_lib.xml
@@ -66,6 +66,12 @@
SASL Error Logging
in the SASL User's Guide.
+ Unlike in "plain Erlang", proc_lib processes will not generate
+ error reports, which are written to the terminal by the
+ emulator and do not require SASL to be started. All exceptions are
+ converted to exits which are ignored by the default
+ error_logger handler.
+
The crash report contains the previously stored information, such
as ancestors and initial function, the termination reason, and
information about other processes that terminate as a result
--
cgit v1.2.3