Fix conflicting checks.

The if statement would never be true.
With this fix the functionality is preserved with some more information in case of error.