caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Julien Signoles <Julien.Signoles@lri.fr>
To: Luca Pascali <luca@barettadeit.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] exception Failure and failwith
Date: Tue, 21 Jun 2005 11:30:17 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0506211124590.10457@pc8-102> (raw)
In-Reply-To: <42B7D0FD.5090305@barettadeit.com>


> It's all about the failwith function of pervasives (that simply raises
> an exception Failure of string).
> Normally, that exception can be cought by means of a try...with using as
> clause something like
> | Failure s -> .....
>
> But what if I want to catch the Failure exception? :-/
> It seems that no module defines it, so I did not find any way to
> identify the exception.

You're right: no module defines Failure. But you can make an alias for the
primitive Failure and use it:

==========
exception Prim_Failure = Failure
exception Failure
let f () = failwith ""
let () =
  try f (); assert false
  with Prim_Failure _ -> print_endline "primitive failure"
     | Failure        -> print_endline "redefined failure"
==========

Hope this helps,
Julien Signoles
-- 
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)


      parent reply	other threads:[~2005-06-21  9:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-21  8:34 Luca Pascali
2005-06-21  9:07 ` [Caml-list] " Luc Maranget
2005-06-21 11:15   ` Luca Pascali
2005-06-21 11:34     ` Luc Maranget
2005-06-21 18:23       ` sejourne_kevin
2005-06-21 18:55       ` William Lovas
2005-06-23  8:04         ` Luca Pascali
2005-06-21  9:30 ` Julien Signoles [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=Pine.LNX.4.58.0506211124590.10457@pc8-102 \
    --to=julien.signoles@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=luca@barettadeit.com \
    /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).