[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Error handling in Mirage




Le jeudi, 10 juillet 2014 Ã 15:40, Anil Madhavapeddy a Ãcrit :

> That's an interesting point though -- is it better to use 
> Pervasives.Invalid_argument, or define a local Invalid_argument? The only bad 
> implication I can think of using the Pervasives one is that you might 
> accidentally catch one that is rippling up from a deeply nested source, which 
> wouldn't happen if every defines their own exception values.

As we discussed the other day, the semantics of Pervasives.Invalid_argument is 
such that it should *never* be caught. It denotes a programming error from the 
client of the library (in the worst case your program may be in a bad state). 
From [1]:

  Invalid_argument is very much like a failed assertion: it indicates
  that something is wrong in the program itself, [â] Most programs will  
  not catch Invalid_argument, treating as a fatal error. Others will catch it,
  but only to enter a piece of generic "recover from unexpected error"
  code.


  [...]

  I recommend the use of Invalid_argument to report "should never
  happen" conditions at the boundary between library functions and user
  code.


As for everyones defining their own exception, people are just going to use 
catch all handlers all over the placesâ so it may not be a good idea.  

Best,

Daniel

[1] https://sympa.inria.fr/sympa/arc/caml-list/2007-10/msg00475.html



_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.