more try/catch confusion

Brian Acton acton@REDACTED
Wed Apr 7 00:07:00 CEST 2010


Hi guys,

I recently went down the road of doing some xml parsing. Using the xmerl
libraries, I tried writing the following construct:

1> try xmerl_scan:file("broken.xml") catch H -> H end.
2404- fatal: unexpected_end
** exception exit: {fatal,

{unexpected_end,{file,"broken.xml"},{line,92},{col,4}}}

I then tried this construct

2> try xmerl_scan:file("broken.xml") of I -> I catch J -> J end.
2404- fatal: unexpected_end
** exception exit: {fatal,

{unexpected_end,{file,"broken.xml"},{line,92},{col,4}}}

I finally got this to work:

3> case catch xmerl_scan:file("broken.xml") of G -> G end.
2404- fatal: unexpected_end
{'EXIT',{fatal,{unexpected_end,{file,"broken.xml"},
                               {line,92},
                               {col,4}}}}

Now, the question is why do #1 and #2 fail while #3 succeeds? I would have
expected both #1 and #2 to have caught the exception.

--b


More information about the erlang-questions mailing list