compiler-design-eth/test/cd/backend/interpreter/DynamicError.java

32 lines
767 B
Java
Raw Normal View History

2020-01-15 22:38:07 +01:00
package cd.backend.interpreter;
import cd.backend.ExitCode;
import cd.util.FileUtil;
/** Thrown in cases that are not ruled out by static analysis: */
@SuppressWarnings("serial")
public class DynamicError extends RuntimeException {
private ExitCode code;
public DynamicError(String message, ExitCode code) {
super(message);
this.code = code;
}
public DynamicError(Throwable thr, ExitCode code) {
super(thr);
this.code = code;
}
public ExitCode getExitCode() {
return this.code;
}
/**
* Returns a string exactly like the one that
* {@link FileUtil#runCommand(java.io.File, String[], String[], String, boolean)}
* returns when a command results in an error. */
public String format() {
return "Error: " + code.value + "\n";
}
}