launchd notification on abnormal exit

The traditional approach, e.g. with cron jobs, is to pipe standard error to a program like mail that's smart enough not to send you empty mail. The difference with launchd, as you've discovered, is that the mechanism for redirecting standard error is giving a StandardErrorPath for it to be written to, which isn't as convenient for this purpose as ending your crontab entry with | mail ….

My usual solution is to have a wrapper script check the StandardErrorPath and notify me if there's a problem. This can either be part of the same launchd job, so the checking happens before the next scheduled run, or you can have a separate job that just manages the error logs (maybe using a QueueDirectories key).

I think you could also, for example, use a named pipe as your job's StandardErrorPath, but I've never actually tried that.