From b16a1b5c92fc9f128428c93ab3251ba1bf716796 Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 17 Mar 2009 13:45:41 +0000 Subject: [PATCH] IMAP: Improve HttpException error handling git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@448 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/imap/ImapConnection.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/java/davmail/imap/ImapConnection.java b/src/java/davmail/imap/ImapConnection.java index 137ad214..ff8c54d2 100644 --- a/src/java/davmail/imap/ImapConnection.java +++ b/src/java/davmail/imap/ImapConnection.java @@ -430,16 +430,23 @@ public class ImapConnection extends AbstractConnection { } catch (SocketException e) { DavGatewayTray.debug("Connection closed"); } catch (Exception e) { + StringBuilder buffer = new StringBuilder(); + if (e instanceof HttpException) { + buffer.append(((HttpException) e).getReasonCode()).append(" ").append(((HttpException) e).getReason()); + } else { + buffer.append(e); + } + String message = buffer.toString(); try { if (commandId != null) { - sendClient(commandId + " BAD unable to handle request: " + e.getMessage()); + sendClient(commandId + " BAD unable to handle request: "+message); } else { - sendClient("* BYE unable to handle request: " + e.getMessage()); + sendClient("* BYE unable to handle request: "+message); } } catch (IOException e2) { DavGatewayTray.warn("Exception sending error to client", e2); } - DavGatewayTray.error("Exception handling client", e); + DavGatewayTray.error("Exception handling client: "+message, e); } finally { close(); }