added ability to handle custom exceptions