On 10/24/07, Xavier Leroy <Xavier.Leroy@inria.fr> wrote:

I recommend the use of Invalid_argument to report "should never
happen" conditions at the boundary between library functions and user
code.  On the other hand, the "Failure" exception is a bit of a legacy
from earlier designs (Caml Light and even the original LeLisp-based
Caml), and often is not the best way to report "normal error"
conditions: instead, you could consider defining your own exceptions
as Alain suggested, or even have your functions return "option" types
instead of raising exceptions.

Where I work, we have come to dearly love the practice of returning polymorphic variants with explicit  variants for various "normal" error cases.  This is pretty lightweight, and is also very clear and explicit, both when looking at the function signature and at the call point.

y