Adding a try and catch and exception handler.