-
-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exceptions cause error-level logging in addition to rethrowing the exception, but should just include the message in a custom exception #329
Comments
Closing until new information comes up. |
@bbottema I'm having the same issue using version This issue creates unnecessary error reports that is created for error level logs in our application. Here is an example to reproduce this. You just have to set an unknown host: package mail;
import org.simplejavamail.MailException;
import org.simplejavamail.api.email.Email;
import org.simplejavamail.api.mailer.Mailer;
import org.simplejavamail.api.mailer.config.TransportStrategy;
import org.simplejavamail.email.EmailBuilder;
import org.simplejavamail.mailer.MailerBuilder;
public class SimpleMailTest {
public static void main(String[] args) {
try {
String host = "foo.fooexample.com";
int port = 587;
String username = "username";
String password = "password";
Mailer mailer = MailerBuilder.withSMTPServer(host, port, username, password)
.withTransportStrategy(TransportStrategy.SMTP_TLS)
.withDebugLogging(false)
.buildMailer();
// mailer.testConnection();
Email email = EmailBuilder.startingBlank()
.from("Michel Baker", "m.baker@mbakery.com")
.to("mom", "jean.baker@hotmail.com")
.to("dad", "StevenOakly1963@hotmail.com")
.withSubject("My Bakery is finally open!")
.withPlainText("Mom, Dad. We did the opening ceremony of our bakery!!!")
.buildEmail();
mailer.sendMail(email, false);
} catch (MailException e) {
System.err.println("########################## Caught MailException");
e.printStackTrace();
} catch (Throwable e) {
System.err.println("~~~~~~~~~~~~~~~~~~~~~~~~~~ Caught Throwable");
e.printStackTrace();
}
}
} Here is the output. Notice that
|
I still don't see the problem. The library does not log the actual error and does propagate it to the caller. The only error-level detail the library logs in addition to that is the following:
Is this what you are referring to? |
yes. It is that extra error log line I am referring to. In my example it is:
|
I agree, it is not needed if we're rethrowing the exception anyway. Might as well wrap both the cause and the logged message in new exception. |
…ception wrapping the original exception
Fix released in 7.0.2 |
When the SMTP credentials are wrong and at the time of sending email library logs the error itself instead propagating to caller.
org.simplejavamail.mailer.internal.AbstractProxyServerSyncingClosure
Failed to send email:
736007253.1.1625220323405@LP-IND-PUN-59.SSGCORP.local
The text was updated successfully, but these errors were encountered: