Add exception handling mechanism