Fix a traceback when using string exceptions.

We need to check that the first argument to `issubclass()` is a class
before using it, since we have the possibility that it's a string.