Skip to content

Commit 030d971

Browse files
committed
Fail user's activation process when error occured during sending e-mail.
1 parent eb9f5b6 commit 030d971

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/main/java/ru/mystamps/web/service/MailServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import ru.mystamps.web.Url;
4040
import ru.mystamps.web.entity.UsersActivation;
41+
import ru.mystamps.web.service.exception.EmailSendingException;
4142

4243
@RequiredArgsConstructor
4344
public class MailServiceImpl implements MailService {
@@ -98,7 +99,7 @@ public void prepare(MimeMessage mimeMessage) throws Exception {
9899
mailer.send(preparator);
99100

100101
} catch (MailException ex) {
101-
LOG.error("Can't send mail to e-mail " + email, ex); // NOPMD: GuardLogStatementJavaUtil
102+
throw new EmailSendingException("Can't send mail to e-mail " + email, ex);
102103
}
103104
}
104105

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2009-2015 Slava Semushin <[email protected]>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
*/
18+
package ru.mystamps.web.service.exception;
19+
20+
public class EmailSendingException extends RuntimeException {
21+
22+
public EmailSendingException(String message) {
23+
super(message);
24+
}
25+
26+
public EmailSendingException(String message, Throwable cause) {
27+
super(message, cause);
28+
}
29+
30+
public EmailSendingException(Throwable cause) {
31+
super(cause);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)