Fix error message when email fails to send.

Closes elastic/elasticsearch#195

Original commit: elastic/x-pack-elasticsearch@7256a32505
This commit is contained in:
Brian Murphy 2015-04-10 14:22:12 -04:00
parent 3e9c109079
commit b70bdb2b89
2 changed files with 3 additions and 3 deletions

View File

@ -95,7 +95,7 @@ public class EmailAction extends Action<EmailAction.Result> {
} catch (EmailException ee) { } catch (EmailException ee) {
logger.error("could not send email [{}] for watch [{}]", ee, actionId, ctx.watch().name()); logger.error("could not send email [{}] for watch [{}]", ee, actionId, ctx.watch().name());
return new Result.Failure("could not send email. error: " + ee.getMessage()); return new Result.Failure("could not send email for action [" + actionId + "]. error: " + ee.getMessage());
} }
} }

View File

@ -55,7 +55,7 @@ public class InternalEmailService extends AbstractLifecycleComponent<InternalEma
public EmailSent send(Email email, Authentication auth, Profile profile, String accountName) { public EmailSent send(Email email, Authentication auth, Profile profile, String accountName) {
Account account = accounts.account(accountName); Account account = accounts.account(accountName);
if (account == null) { if (account == null) {
throw new EmailException("failed to send email [" + email + "] via account [" + accountName + "]. account does not exist"); throw new EmailException("failed to send email with subject [" + email.subject() + "] via account [" + accountName + "]. account does not exist");
} }
return send(email, auth, profile, account); return send(email, auth, profile, account);
} }
@ -65,7 +65,7 @@ public class InternalEmailService extends AbstractLifecycleComponent<InternalEma
try { try {
email = account.send(email, auth, profile); email = account.send(email, auth, profile);
} catch (MessagingException me) { } catch (MessagingException me) {
throw new EmailException("failed to send email [" + email + "] via account [" + account.name() + "]", me); throw new EmailException("failed to send email with subject [" + email.subject() + "] via account [" + account.name() + "]", me);
} }
return new EmailSent(account.name(), email); return new EmailSent(account.name(), email);
} }