Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Catching exceptions into strings
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-06-10 (14:27)
From: Gaurav Chanda <gaurav_chanda@l...>
Subject: [Caml-list] Catching exceptions into strings

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
        [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>

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 ?


WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: