This module provides functions for pretty-printing errors and exceptions. It is used
by both the
It is possible for the module raising an error to provide additional
information by calling
A map with formatting options.
A fun used to trim the end of the stacktrace. It is
called with module, function, and arity from an entry from the
stacktrace. The fun is to return
fun(_, _, _) -> false end
A fun used to format function arguments for BIF and function calls. By default the following fun will be used:
fun(Term, I) -> io_lib:print(Term, I, 80, 30) end
Start column number. Default is 1.
Format the error reason and stack back-trace caught using
Example:
try
do_something()
catch
C:R:Stk ->
Message = erl_error:format_exception(C, R, Stk),
io:format(LogFile, "~ts\n", [Message])
end
If
Example:
try
erlang:raise(badarg,[],[{error_info,#{}}])
catch
C:R:Stk ->
Message = erl_error:format_exception(C, R, Stk),
io:format(LogFile, "~ts\n", [Message])
end
See
The following functions are to be exported from an Error Info handler.
This callback is called when
The function should return a map with additional information about what have caused the exception. The possible keys of the map are:
If the text returned includes new-lines,
Example:
1> c(my_error_module). {ok,my_error_module} 2> my_error_module:atom_to_string(1). ** exception error: my_error_module: badarg in function my_error_module:atom_to_string/1 called as my_error_module:atom_to_string(1) *** argument 1: should be an atom *** optional general information