Adding a condition to send email, when an error occurs on the server side