mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
- Improved the error reporting mechanism in LDAP setting.
- improved FormValidation.error(...) so that one can easily send the full stack trace. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@29612 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
67cc6af159
commit
a168fc472a
4 files changed
+51
-4
No files matched your search
@@ -519,12 +519,12 @@ public class LDAPSecurityRealm extends SecurityRealm {
|
||||
} catch (UnknownHostException x) {
|
||||
return FormValidation.error(Messages.LDAPSecurityRealm_UnknownHost(x.getMessage()));
|
||||
} catch (IOException x) {
|
||||
return FormValidation.error(Messages.LDAPSecurityRealm_UnableToConnect(server, x.getMessage()));
|
||||
return FormValidation.error(x,Messages.LDAPSecurityRealm_UnableToConnect(server, x.getMessage()));
|
||||
}
|
||||
|
||||
// otherwise we don't know what caused it, so fall back to the general error report
|
||||
// getMessage() alone doesn't offer enough
|
||||
return FormValidation.error(Messages.LDAPSecurityRealm_UnableToConnect(server, e));
|
||||
return FormValidation.error(e,Messages.LDAPSecurityRealm_UnableToConnect(server, e));
|
||||
} catch (NumberFormatException x) {
|
||||
// The getLdapCtxInstance method throws this if it fails to parse the port number
|
||||
return FormValidation.error(Messages.LDAPSecurityRealm_InvalidPortNumber());
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ZipExtractionInstaller extends ToolInstaller {
|
||||
} catch (MalformedURLException x) {
|
||||
return FormValidation.error(Messages.ZipExtractionInstaller_malformed_url());
|
||||
} catch (IOException x) {
|
||||
return FormValidation.error(Messages.ZipExtractionInstaller_could_not_connect());
|
||||
return FormValidation.error(x,Messages.ZipExtractionInstaller_could_not_connect());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package hudson.util;
|
||||
|
||||
import hudson.EnvVars;
|
||||
import hudson.Functions;
|
||||
import hudson.Launcher;
|
||||
import hudson.ProxyConfiguration;
|
||||
import hudson.Util;
|
||||
@@ -161,6 +162,42 @@ public abstract class FormValidation extends IOException implements HttpResponse
|
||||
return ok(String.format(format,args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends out a string error message, with optional "show details" link that expands to the full stack trace.
|
||||
*
|
||||
* <p>
|
||||
* Use this with caution, so that anonymous users do not gain too much insights into the state of the system,
|
||||
* as error stack trace often reveals a lot of information. Consider if a check operation needs to be exposed
|
||||
* to everyone or just those who have higher access to job/hudson/etc.
|
||||
*/
|
||||
public static FormValidation error(Throwable e, String message) {
|
||||
return _error(Kind.ERROR, e, message);
|
||||
}
|
||||
|
||||
public static FormValidation warning(Throwable e, String message) {
|
||||
return _error(Kind.WARNING, e, message);
|
||||
}
|
||||
|
||||
private static FormValidation _error(Kind kind, Throwable e, String message) {
|
||||
if (e==null) return _errorWithMarkup(Util.escape(message),kind);
|
||||
|
||||
return _errorWithMarkup(Util.escape(message)+
|
||||
" <a href='#' class='showDetails'>(show details)</a><pre style='display:none'>"
|
||||
+ Functions.printThrowable(e) +
|
||||
"</pre>",kind
|
||||
);
|
||||
}
|
||||
|
||||
public static FormValidation error(Throwable e, String format, Object... args) {
|
||||
return error(e,String.format(format,args));
|
||||
}
|
||||
|
||||
public static FormValidation warning(Throwable e, String format, Object... args) {
|
||||
return warning(e,String.format(format,args));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sends out an HTML fragment that indicates an error.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user