If a single call to the binding code can return several of Failure payloads, then yes, I guess you cannot escape using specific text on the warning text. You can either disable the warning locally using a @warning attribute (if your backward-compatibility requirement do not go back before ppx attributes), or move the string-testing logic to inside the pattern-matching clause (a guard would also work). Note that the string-testing solution *can* be made robust if the library/binding exports identifiers containing the value of the error messages, and you test against them. Note that since BenoƮt Vaugon's optimization work in 4.02.0 pattern-matching on several literal strings is sensibly faster than a series of string-equality test, so in performance-critical code it makes sense to use pattern-matching on string -- but it does not need to be part of the try-handler patterns directly, it can be only in the (Failure err -> ...) clause. Thanks for your comments (and William's) on the documentation. Feel free to add additional comments on the related ticket William created, PR#7245 http://caml.inria.fr/mantis/view.php?id=7245 On Wed, Apr 27, 2016 at 1:17 PM, Adrien Nader wrote: > On Wed, Apr 27, 2016, Gabriel Scherer wrote: > > We now have a section of the reference manual (which has been updated to > > 4.03) on Warnings, and this particular warning is documented there: > > http://caml.inria.fr/pub/docs/manual-ocaml/comp.html#s:comp-warnings > > > > Feedback (for example as Mantis tickets) on which warnings are confusing > > and would deserve additional documentation -- or even patches to provide > > this documentation -- are warmly welcome. > > Thanks for the documentation update. I've found the warning fairly > confusing and this makes it clear. > > As a small note, in a library I use (I won't name it because I haven't > checked if there were a version more recent than a couple years), C > bindings use the built-in Failure exception. I guess this is because it > is so much more convenient when it comes to making C bindings. > Am I right that such scenario will always trigger this warning because > the warning attribute will never be removed from the OCaml upstream > definition of Failure? > > PS: my only comment about the warning is maybe to state that all(?) > exceptions from the stdlib have the corresponding attribute set. > > -- > Adrien Nader >