more context incase of error

This commit is contained in:
Doug MacEachern 2006-03-04 07:28:15 +00:00
parent c91d0991ad
commit 9fa41cc1c7
1 changed files with 11 additions and 3 deletions

View File

@ -27,12 +27,20 @@ public class SigarProcess implements SigarProcessMBean {
this.sigarImpl.close(); this.sigarImpl.close();
} }
private RuntimeException unexpectedError(String type,
SigarException e) {
String msg =
"Unexected error in Sigar.get" + type +
": " + e.getMessage();
return new IllegalArgumentException(msg);
}
private synchronized ProcMem getMem() { private synchronized ProcMem getMem() {
try { try {
long pid = this.sigar.getPid(); long pid = this.sigar.getPid();
return this.sigar.getProcMem(pid); return this.sigar.getProcMem(pid);
} catch (SigarException e) { } catch (SigarException e) {
throw new IllegalArgumentException(); throw unexpectedError("Mem", e);
} }
} }
@ -41,7 +49,7 @@ public class SigarProcess implements SigarProcessMBean {
long pid = this.sigar.getPid(); long pid = this.sigar.getPid();
return this.sigar.getProcTime(pid); return this.sigar.getProcTime(pid);
} catch (SigarException e) { } catch (SigarException e) {
throw new IllegalArgumentException(); throw unexpectedError("Time", e);
} }
} }
@ -50,7 +58,7 @@ public class SigarProcess implements SigarProcessMBean {
long pid = this.sigar.getPid(); long pid = this.sigar.getPid();
return this.sigar.getProcFd(pid); return this.sigar.getProcFd(pid);
} catch (SigarException e) { } catch (SigarException e) {
throw new IllegalArgumentException(); throw unexpectedError("Fd", e);
} }
} }