caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Raj Bandyopadhyay <rajb@rice.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Indentifying OCaml exceptions from C
Date: Thu, 01 May 2008 09:46:09 +0200	[thread overview]
Message-ID: <48197541.8010809@frisch.fr> (raw)
In-Reply-To: <481895A4.9080407@rice.edu>

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


      reply	other threads:[~2008-05-01  7:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-30 15:52 Raj Bandyopadhyay
2008-05-01  7:46 ` Alain Frisch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48197541.8010809@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=rajb@rice.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).