test: generalize HasReason and use it in FailFmtWithError
Standardized boost exception checking in recent tests introduced in https://github.com/bitcoin/bitcoin/pull/30546#discussion_r1756493521 by extending HasReason to accept const char* through string_view in operator().
Note that HasReason only checks partial matches - but since we're specifying the whole error string, it doesn't affect us in this case.