caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Catching exceptions into strings
@ 2002-06-10 14:27 Gaurav Chanda
  2002-06-10 15:07 ` Xavier Leroy
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Gaurav Chanda @ 2002-06-10 14:27 UTC (permalink / raw)
  To: caml-list

Hello

I want to catch exceptions into strings. I do not want to have pre-defined exceptions in my module which can be handled. I want to catch exceptions like "floating point exceptions" etc. 

I wrote the follwing piece of code:

value divide2 p = 2/p ;

value foo p =
        try divide2 p
        with
        [e -> let _ =  do {print_string (Printexc.to_string e);flush stdout} in  9];

value _ = foo 0;

(This code is in the Camlp4 revised syntax).

When I compile and run this code, I get :

Floating point exception


However, after loading OCAML, if I use this file, I get

 value divide2 : int -> int = <fun>
value arbit : int -> int = <fun>
Division_by_zero

That is, in the latter case, I get what I want but in the former case, I don't. Could you help me solve this problem ?

Gaurav







_______________________________________________________
WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes
-------------------
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


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2002-06-17 21:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-10 14:27 [Caml-list] Catching exceptions into strings Gaurav Chanda
2002-06-10 15:07 ` Xavier Leroy
2002-06-10 21:57 ` Michael Vanier
2002-06-12  8:53   ` Xavier Leroy
2002-06-12  9:36     ` Michael Vanier
2002-06-17 12:48       ` Xavier Leroy
2002-06-17 16:10         ` Ken Rose
2002-06-11  9:23 ` Guillaume Valadon
2002-06-11 13:28   ` David Chase
2002-06-11 15:37     ` Xavier Leroy
2002-06-11 17:44       ` David Chase
2002-06-12  8:33         ` Xavier Leroy
2002-06-11 21:19       ` Michael Vanier
2002-06-14 21:23       ` John Carr
2002-06-17 12:31         ` Xavier Leroy
2002-06-17 21:08           ` John Carr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).