Extract logErrorOrSendEmail