Restrict generality of a caught exception.

This way, we can know better what is the reason for a failure.
Avoid converting an exception to a string.

We already have the information at our disposal there as an integer, which
is exactly what we want to check.