[PATCH] email: Catch exceptions during send

David Soria Parra sn_ at gmx.net
Sun Jul 26 19:28:17 CDT 2009

# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1248654444 -7200
# Node ID 0f74f3bed5e0946d4ecbcc5fd03e24be34921761
# Parent  1f5fa2fbbc6a5771f2058c0a596d9e0f2bb8187a
email: Catch exceptions during send.

Catch SMTPlib exceptions to avoid mercurial showing a backtrace during
an e.g. authentication error.

diff --git a/mercurial/mail.py b/mercurial/mail.py
--- a/mercurial/mail.py
+++ b/mercurial/mail.py
@@ -36,7 +36,10 @@
     if username and password:
         ui.note(_('(authenticating to mail server as %s)\n') %
-        s.login(username, password)
+        try:
+            s.login(username, password)
+        except smtplib.SMTPException, inst:
+            raise util.Abort(inst)
     def send(sender, recipients, msg):

More information about the Mercurial-devel mailing list