Loading ...
Sorry, an error occurred while loading the content.

Re: "ocaml_beginners"::[] Catching exceptions from OCaml callbacks

Expand Messages
  • Nicolas Cannasse
    ... you have to call callback_exn instead of callback and then test for Is_exception_result(foo) and if true you can get the raised exception with
    Message 1 of 1 , Jul 28, 2003
    • 0 Attachment
      >
      > I may be missing something here but in Ch 18 of the manual, is there
      > anything which describes how to catch the case when a OCaml callback
      > throws an exception.
      >
      > eg:
      >
      > value foo = callback (*caml_named_value ("my function"), arg);
      >
      > and the registered function throws an exception instead of returning
      > in the normal way; is there some way to test for this?

      you have to call callback_exn instead of callback and then test for
      Is_exception_result(foo) and if true you can get the raised exception with
      Extract_exception(foo). All of theses are defined in lib/caml/callback.h

      Nicolas Cannasse
    Your message has been successfully submitted and would be delivered to recipients shortly.