[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2008-05-01 (07:46) |
From: | Alain Frisch <alain@f...> |
Subject: | Re: [Caml-list] Indentifying OCaml exceptions from C |
Raj Bandyopadhyay wrote: > Hi ocaml folks > > I have a C program that makes callbacks to the OCaml runtime via the > callback_exn() mechanism. Unfortunately, the OCaml code is raising some > exception. It seems to be one of the built-in OCaml exceptions, and not > something that I have defined in my OCaml code. > > I would like to know what is the easiest/correct way to identify the > exact OCaml exception being raised, so I can debug this program. You can use the macros Is_exception_result and Extract_exception (defined in callback.h) to check whether the result of callback_exn is an exception and to retrieve the exception value in that case. The first field of this value points to a block with one field pointing to the string representing the exception's constructor name. The other fields of the exception value are the exception's arguments. -- Alain