Implemented exception handling.