add SigarException.setMessage and use in FileInfo to include file name

This commit is contained in:
Doug MacEachern 2007-01-23 00:42:18 +00:00
parent 2dcff7e5c9
commit fdb740265a
2 changed files with 27 additions and 7 deletions

View File

@ -425,13 +425,18 @@ public class FileInfo extends FileAttrs {
FileInfo info = new FileInfo();
if (followSymlinks) {
info.gather(sigar, name);
info.lstat = false;
}
else {
info.gatherLink(sigar, name);
info.lstat = true;
try {
if (followSymlinks) {
info.gather(sigar, name);
info.lstat = false;
}
else {
info.gatherLink(sigar, name);
info.lstat = true;
}
} catch (SigarException e) {
e.setMessage(name + ": " + e.getMessage());
throw e;
}
info.sigar = sigar;

View File

@ -23,7 +23,22 @@ package org.hyperic.sigar;
*/
public class SigarException extends Exception {
private String message;
public SigarException () { super(); }
public SigarException (String s) { super(s); }
public String getMessage() {
if (this.message != null) {
return this.message;
}
else {
return super.getMessage();
}
}
void setMessage(String message) {
this.message = message;
}
}