Added exception handling to example