Determine where a match fails
Fri Jan 6 00:04:41 CET 2006
--- Sean Hinde <> wrote:
> On 4 Jan 2006, at 17:15, Dave Smith wrote:
> > Greetings,
> > Is there a way to determine the File/Line where a
> badmatch error is
> > generated? Obviously, you get a stack trace with
> the function call,
> > but more often than not, that's not quite
> descriptive enough, since
> > all you get is the value that didn't
> > Any guidance would be appreciated. :)
> You might like to try out the smart exceptions
> package from jungerl.
> I believe this adds such things.
> I've never actually tried it myself, but it might
> just do the job.
I use smart_exceptions for my development and find it
very convenient; but note that there are a couple of
1. It doesn't handle variables exported out of
expressions. This is due to three things: (i) the
smart_exceptions functionality is provided by
rewriting the code so that line and module (and other
stuff) is added at most places where an exception can
occur; (ii) the erlang compiler demands that all
clauses export the same variables, even if some of
them will never terminate normally; (iii) computing
the exported variables of an expression is nontrivial.
2. On some R10 Erlang releases, using smart_exceptions
triggered a compiler bug (which generated incorrect
object code). I haven't seen this for recent R10
(Finally, as an aside, a better solution would be for
the compiler to insert the equivalent information and
for the VM to use it when an exception occurs.)
Yahoo! DSL Something to write home about.
Just $16.99/mo. or less.
More information about the erlang-questions