Added test case to test runtime exceptions
Cleaned up the try catch  logic