smart exceptions

Thomas Lindgren thomasl_erlang@REDACTED
Tue Mar 7 16:27:41 CET 2006

--- Serge Aleynikov <serge@REDACTED> wrote:

> 1. Am I correct to say that when using smart
> exceptions, the beam files 
> in jungerl/lib/smart_exceptions/ebin are only needed
> at compile-time and 
> not at run-time?

With the "normal" use of smart exceptions, you only
need the transform at compile time.

(Theoretically, you can also make it plug in other
stuff to do at an error, but this hasn't really been

> 2. Is there a way to use smart_exceptions in order
> to include 
> function/line info in the uncaught throw exception?

I'm not convinced that's a good default behaviour,
since the thrown value is sometimes used as a valid
return value. Changing a thrown value may then lead to
amusing runtime problems as pattern matches fail.

If you still want to do it, hack the code so that
throw/1 is rewritten like exit/1. Eh, jungerl seems to
be very slow, so I can't show you directly ... but it
should basically be a matter of copy+paste+modify a
line where a call to exit(Rsn) is detected and
rewriting the copied line to do the same with throw.

Note that the code does this rewrite in two ways,
depending on a compile-time flag. It's pretty
straightforward, just be sure that you are getting
your modified version.

PS. OTP, not that I know if you're thinking about it,
but if you want to introduce line numbers etc. in
exceptions, please mail me before you start hacking.
There are a couple of things to think about, and do,
to get it right, or, at least, to get it much more
right than smart_exceptions.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the erlang-questions mailing list