Refined the matching of strings in error messages.