TornadoVM
TornadoVM copied to clipboard
TornadoException-s do not follow std. Java coding practices
TornadoRuntimeException, TornadoUnimplementedException, TornadoTaskRuntimeException, TornadoBailoutRuntimeException and probably others do not follow standard Java coding practices for Exception classes and contains redundant code. For example, TornadoBailoutRuntimeException:
CURRENTLY:
public class TornadoBailoutRuntimeException extends RuntimeException {
private final String message;
private Exception e;
static final String RESET = "\u001B[0m";
static final String RED = "\u001B[31m";
public TornadoBailoutRuntimeException(final String msg) {
message = RED + msg + RESET;
}
public TornadoBailoutRuntimeException(final String msg, Exception e) {
message = RED + msg + RESET;
this.e = e;
}
public Exception getException() {
return this.e;
}
@Override
public String getMessage() {
return message;
}
}
SHOULD BE:
public class TornadoBailoutRuntimeException extends RuntimeException {
static final String RESET = "\u001B[0m";
static final String RED = "\u001B[31m";
public TornadoBailoutRuntimeException(final String msg) {
super(RED + msg + RESET);
}
public TornadoBailoutRuntimeException(final String msg, Exception e) {
super(RED + msg + RESET, e);
}
// May be removed as well - because it's a synonim for getCause()
public Throwable getException() {
return getCause();
}
}
The fixed version is not only more compact, but prints exception traces correctly, because the chain of exceptions is initialized (unlike it's done currently).