File: BeagleException.java

package info (click to toggle)
libhmsbeagle 2.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,756 kB
  • ctags: 2,341
  • sloc: cpp: 17,296; ansic: 5,842; java: 1,696; sh: 1,325; python: 486; makefile: 335; xml: 299
file content (37 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download | duplicates (9)
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;
}