1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package beagle;
/**
* @author Andrew Rambaut
* @author Marc Suchard
*/
public class BeagleException extends RuntimeException {
public BeagleException(String functionName, int errCode) {
this.functionName = functionName;
this.errCode = errCode;
}
@Override
public String getMessage() {
BeagleErrorCode code = null;
for (BeagleErrorCode c : BeagleErrorCode.values()) {
if (c.getErrCode() == errCode) {
code = c;
}
}
if (code == null) {
return "BEAGLE function, " + functionName + ", returned error code " + errCode + " (unrecognized error code)";
}
return "BEAGLE function, " + functionName + ", returned error code " + errCode + " (" + code.getMeaning() + ")";
}
public String getFunctionName() {
return functionName;
}
public int getErrCode() {
return errCode;
}
private final String functionName;
private final int errCode;
}
|