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] assert caught by try with _
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jason Hickey <jyh@c...>
Subject: Re: [Caml-list] assert caught by try with _
Chris Hecker wrote:
> Is the the "right thing" for assert to be caught by a try ... with _ -> 
> ... block?

I don't know.  It seems reasonable to have exceptional conditions caught 
by the exception handler...

However, it may be reasonable to ask for more than one exception 
type--it seems like poor software engineering to statically list *all* 
the possible reasonable exceptions in a try/with block, except for 
Assert_failure.  This idea will fail as new exceptions are added.

To help avoid this problem, in our work we generally declare a type of 
application errors (not the exact syntax but close enough):

    type application_error =
     | BadIdea of string
     | IWouldIfICouldButICantSoIWont
     | ...

    exception ApplicationError of application_error

All raises are of the form (raise (ApplicationError ...)), and the 
"default" exception handler is (try ... with ApplicationError _ -> ...). 
  This idea works ok, but is not scalable.


Jason Hickey        
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: