It is important that a gateway provide or store as much information as possible if an error occurs. You can implement four levels of error handling:
Retry the failed operation in case the problem is temporary, as in a communication failure.
Send a nondelivery report for the message. (Note that a gateway should not send a nondelivery report for a report.)
If the gateway cannot send the message and also cannot send a nondelivery report (for example, if the network is down), save the message, write an entry in the error log, and alert the administrator. Retry the operation later.
If you can continue processing only by deleting the message, then delete the message, write an entry to the error log, and alert the administrator. An example of this is when the gateway receives a message that is too large to store or send.