<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/35dded66c6740523de25c1e3cc6579d6"
  from="David Fox &lt;david.fox@l...&gt;"
  author="David Fox"
  date="2002-07-13T20:28:23"
  subject="Re: [Caml-list] Exceptions and at_exit"
  prev="2002/07/ac9e2089becac45a6611e9f1e9a29ae0"
  next="2002/07/591aad917776652dbf0a2c8674ffc0ae"
  prev-in-thread="2002/06/0eac35b9b56fcae9a3c59800414d1a56"
  next-in-thread="2002/07/2fd34624553a8aed699527062ffd1fc0"
  prev-thread="2002/06/f15aadd13d3b489eec81f1c0af2b9fd9"
  next-thread="2002/06/2d1a7e2c6e0137c0802dd574bf3e64bd"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Exceptions and at_exit">
<msg 
  url="2002/06/f0b83f782bbe62a3ebc19986232eb0dd"
  from="David Fox &lt;david@l...&gt;"
  author="David Fox"
  date="2002-06-04T21:01:17"
  subject="[Caml-list] Exceptions and at_exit">
<msg 
  url="2002/06/0eac35b9b56fcae9a3c59800414d1a56"
  from="Remi VANICAT &lt;vanicat@l...&gt;"
  author="Remi VANICAT"
  date="2002-06-04T21:09:15"
  subject="Re: [Caml-list] Exceptions and at_exit">
</msg>
<msg 
  url="2002/07/35dded66c6740523de25c1e3cc6579d6"
  from="David Fox &lt;david.fox@l...&gt;"
  author="David Fox"
  date="2002-07-13T20:28:23"
  subject="Re: [Caml-list] Exceptions and at_exit">
<msg 
  url="2002/07/2fd34624553a8aed699527062ffd1fc0"
  from="William Lovas &lt;wlovas@s...&gt;"
  author="William Lovas"
  date="2002-07-13T20:44:55"
  subject="Re: [Caml-list] Exceptions and at_exit">
<msg 
  url="2002/07/062aebd744c5ccd9e413275f56bb43ea"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-14T17:35:20"
  subject="Re: [Caml-list] Exceptions and at_exit">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
David Fox &lt;david@lindows.com&gt; writes:

&gt; I have some at_exit functions that must execute before my program
&gt; exits, but I also want to see a traceback of any exception that
&gt; occurs.  Can I catch the exception, print a traceback like the one you
&gt; get when you exit and then call exit?  Or can I catch the exception,
&gt; execute the at_exit functions, and then re-raise the exception?  How
&gt; *do* you re-raise an exception, anyway?  Do you just catch the
&gt; exception and raise it?

My confusion about re-raising exceptions was caused by the fact that
you get different behavior if you say something like

  try ... with
    Failure msg -&gt; &lt;do some stuff&gt;; raise (Failure msg)

vs something like

  try ... with
    exn -&gt;
       begin match exn with Failure msg -&gt; &lt;do some stuff&gt; end;
       raise exn

In the second case, you are re-raising the exception, in the first
you are raising a new exception and your original traceback is lost.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

