Added a simple catch exceptions logic.