Check exception type and message
Refactor to use message instead of str