IMAP: Improve HttpException error handling

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@448 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-03-17 13:45:41 +00:00
parent cf4a925b5a
commit b16a1b5c92
1 changed files with 10 additions and 3 deletions

View File

@ -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();
}