}
IStatus getExceptionStatus(Exception e, String message) {
JSchException jschEx = getJSchException(e);
if (jschEx != null && jschEx instanceof HostFingerprintException) {
HostFingerprintException cause = (HostFingerprintException) jschEx;
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, cause.getMessage(), addRepositoryInfo(cause.formJson()), cause);
}
// JSch handles auth fail by exception message, another one handles only by exception message is "invalid privatekey: ..."
if (jschEx != null
&& jschEx.getMessage() != null
&& (jschEx.getMessage().toLowerCase(Locale.ENGLISH).contains("auth fail") || jschEx.getMessage().toLowerCase(Locale.ENGLISH).contains("invalid privatekey"))) { //$NON-NLS-1$
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_UNAUTHORIZED, jschEx.getMessage(), addRepositoryInfo(new JSONObject()), jschEx);
}
// Log connection problems directly
if (e.getCause() instanceof TransportException) {
TransportException cause = (TransportException) e.getCause();
if (matchMessage(JGitText.get().serviceNotPermitted, cause.getMessage())) {
// HTTP connection problems are distinguished by exception message
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, cause.getMessage(), addRepositoryInfo(new JSONObject()), cause);
} else if (matchMessage(JGitText.get().notAuthorized, cause.getMessage())) {
// HTTP connection problems are distinguished by exception message
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_UNAUTHORIZED, cause.getMessage(), addRepositoryInfo(new JSONObject()), cause);
} else if (cause.getMessage().endsWith("username must not be null.") || cause.getMessage().endsWith("host must not be null.")) { //$NON-NLS-1$ //$NON-NLS-2$
// see com.jcraft.jsch.JSch#getSession(String, String, int)
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, cause.getMessage(), addRepositoryInfo(new JSONObject()), cause);
} else if (e instanceof GitAPIException) {
// Other HTTP connection problems reported directly
return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message, addRepositoryInfo(new JSONObject()), e);
} else {
// Other HTTP connection problems reported directly