1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
[;1m-spec erlang:raise(Class, Reason, Stacktrace) -> badarg[0m
[;1m when[0m
[;1m Class :: error | exit | throw,[0m
[;1m Reason :: term(),[0m
[;1m Stacktrace :: raise_stacktrace().[0m
Types:
-type raise_stacktrace() ::
[{module(), atom(), arity() | [term()]} |
{function(), [term()]}] |
[{module(), atom(), arity() | [term()], [{atom(), term()}]} |
{function(), [term()], [{atom(), term()}]}].
Raises an exception of the specified class, reason, and call stack
backtrace (stacktrace).
[;;4mClass[0m is [;;4merror[0m, [;;4mexit[0m, or [;;4mthrow[0m. So, if it were not for the
stacktrace, [;;4merlang:raise(Class, Reason, Stacktrace)[0m is
equivalent to [;;4merlang:Class(Reason)[0m (given that [;;4mClass[0m is a
valid class).
[;;4mReason[0m can be any term.
[;;4mStacktrace[0m is a list as provided in a try-catch clause.
try
...
catch Class:Reason:Stacktrace ->
...
end
That is, a list of four-tuples [;;4m{Module, Function, Arity | Args,[0m
[;;4mLocation}[0m, where [;;4mModule[0m and [;;4mFunction[0m are atoms, and the third
element is an integer arity or an argument list. The stacktrace
can also contain [;;4m{Fun, Args, Location}[0m tuples, where [;;4mFun[0m is a
local fun and [;;4mArgs[0m is an argument list.
Element [;;4mLocation[0m at the end is optional. Omitting it is
equivalent to specifying an empty list.
The stacktrace is used as the exception stacktrace for the calling
process; it is truncated to the current maximum stacktrace depth.
As evaluating this function causes the process to terminate, it
has no return value unless the arguments are invalid, in which
case the function returns the error reason [;;4mbadarg[0m. If you want
to be sure not to return, you can call [;;4merror(erlang:raise(Class,[0m
[;;4mReason, Stacktrace))[0m and hope to distinguish exceptions later.
See the reference manual about errors and error handling for
more information about exception classes and how to catch
exceptions.
|