Check for specific exception raised in FlagCollection instead of string content of exception

This closes one of the windows 64-bit test failures on appveyor seen in #2755
Just curious, why does the content of the error mismatch? What does it give on Windows? If at all possible, I'd at least check the first few words of the exception to make sure it's likely to be the right error.