Since version 10 (at least 10.0.2 but I think 10.0.0) there is
Failure and since version 10.2 there is also
FailureQ. As often the documentation is somewhat vague and says "Failure is generated by Interpreter and related functions.".
To me it looks like
Failure is not more than a symbol which can be used as the head of an expression in a return value or an argument to
Throw which indicates that something went wrong. A
Failure expressions is expected to have two arguments, the first being a tag to be able to match against, the second an association as a second argument which can hold additional information about what went wrong. That is very much what an Exception object in other languages would contain and has obvious applications.
The question is whether it would be a good idea to rely on these symbols for my own code or whether it is more safe to run my own "exceptions" package. I currently don't see any disadvantage of just using
Failure in that way which would save me from providing a new symbol in an additional package which creates dependencies and I could also take advantage of an already defined
FailureQ and - less important but nice to have - formatting of these failure-expressions.
Any thoughts and experience out there? Any recommendations from WRI known to be published anywhere?