How to manage error notifications for background tasks

Here is what I use to send myself an email from an uplink that has communication errors: How to handle unexpected disconnect in Uplink program?