Added support for emailing errors.