Add exception handling for sql and sendemail calls