I'm new to Erlang and I found how to handle exceptions in a Users Guide, but not how to throw them. Is it possible to define and then throw my own exception?
this is from raising erlang exceptions
Example of raising an Erlang exception with exit(Why).
-module(exceptions).
-export([sample_error/0]).
sample_error() -> throw(“some bad happened”).
Now lets compile our exceptions module, invoke the sample_error() function and observe >the output of the raised exception.
erlc –o ebin src/exceptions.erl
erl –pa ebin
1> exceptions:sample_error().
** exception throw: "some bad happened"
in function exceptions:sample_error/0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With