find win32 error message even if it's nested.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3497 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-06-22 00:31:13 +00:00
1 parent 1659f41176
commit 8aae7754e1
1 file changed
+10 -3
+10 -3
View File
@@ -201,16 +201,23 @@ public class Util {
listener.getLogger().println(msg);
}
public static String getWin32ErrorMessage(IOException e) {
return getWin32ErrorMessage((Throwable)e);
}
/**
* Extracts the Win32 error message from {@link IOException} if possible.
* Extracts the Win32 error message from {@link Throwable} if possible.
*
* @return
* null if there seems to be no error code or if the platform is not Win32.
*/
public static String getWin32ErrorMessage(IOException e) {
public static String getWin32ErrorMessage(Throwable e) {
String msg = e.getMessage();
if(msg==null)
if(msg==null) {
if(e.getCause()!=null)
return getWin32ErrorMessage(e.getCause());
return null; // no message
}
Matcher m = errorCodeParser.matcher(msg);
if(!m.matches())
return null; // failed to parse