implements exception handling.