提交 9bfced32 编写于 作者: K kohsuke

Improved the error diagnosis, after seeing...

Improved the error diagnosis, after seeing http://www.nabble.com/error-installing-hudson-as-a-windows-service-tt21378003.html

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@14320 71c3de6d-444a-0410-be80-ed276b4c234a
上级 07794e30
......@@ -13,25 +13,31 @@ public class DotNet {
* Returns true if the .NET framework of the given version (or greater) is installed.
*/
public static boolean isInstalled(int major, int minor) {
// see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm
// observation in my registry shows that the actual key name can be things like "v2.0 SP1"
// or "v2.0.50727", so the regexp is written to accomodate this.
RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework");
try {
for( String keyName : key.getSubKeys() ) {
Matcher m = VERSION_PATTERN.matcher(keyName);
if(m.matches()) {
int mj = Integer.parseInt(m.group(1));
if(mj>=major) {
int mn = Integer.parseInt(m.group(2));
if(mn>=minor)
return true;
// see http://support.microsoft.com/?scid=kb;en-us;315291 for the basic algorithm
// observation in my registry shows that the actual key name can be things like "v2.0 SP1"
// or "v2.0.50727", so the regexp is written to accomodate this.
RegistryKey key = RegistryKey.LOCAL_MACHINE.openReadonly("SOFTWARE\\Microsoft\\.NETFramework");
try {
for( String keyName : key.getSubKeys() ) {
Matcher m = VERSION_PATTERN.matcher(keyName);
if(m.matches()) {
int mj = Integer.parseInt(m.group(1));
if(mj>=major) {
int mn = Integer.parseInt(m.group(2));
if(mn>=minor)
return true;
}
}
}
return false;
} finally {
key.dispose();
}
return false;
} finally {
key.dispose();
} catch (JnaException e) {
if(e.getErrorCode()==2) // thrown when openReadonly fails because the key doesn't exist.
return false;
throw e;
}
}
......
......@@ -8,7 +8,14 @@ import hudson.Util;
* @author Kohsuke Kawaguchi
*/
public class JnaException extends RuntimeException {
private final int errorCode;
public JnaException(int errorCode) {
super("Win32 error: "+errorCode+" - "+Util.getWin32ErrorMessage(errorCode));
this.errorCode = errorCode;
}
public int getErrorCode() {
return errorCode;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册