Well, you could advise
But do you really need/want this to take effect for calls to
message, i.e., including for calls that your code does not make?
If what you are really trying to do is "build a contingency engine for common errors" then it sounds like what it would be helpful to define your own error symbols. To do that, you use
define-error - see the Elisp manual, node Error Symbols.
And see these nodes:
Note: In versions of Emacs prior to Emacs 24.4, there was no
define-error. You accomplished the same thing using symbol property
error-conditions (and you can still do this). Here are the Emacs 24.4 and Emacs 24.3 definitions of error condition
bookmark-error-no-filename, for instance:
Emacs 24.4 (+):
(define-error 'bookmark-errors nil)
"Bookmark has no associated file (or directory)" 'bookmark-errors)
'(error bookmark-errors bookmark-error-no-filename))
"Bookmark has no associated file (or directory)")
P.S. If my guess is right about what your question is really about, please consider editing the question (at least the title) to make it clear.