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