improve error handling

This commit is contained in:
Jonathan Shook 2021-01-25 14:25:46 -06:00
parent acfe9889d2
commit cd86ea756d
2 changed files with 6 additions and 4 deletions

View File

@ -7,6 +7,11 @@ public class InvalidStatusCodeException extends RuntimeException {
private final Pattern ok_status;
private final int statusCode;
@Override
public String getMessage() {
return "Server returned status code '" + statusCode + "' which did not match ok_status '" + ok_status.toString() + "'";
}
public InvalidStatusCodeException(long cycleValue, Pattern ok_status, int statusCode) {
this.cycleValue = cycleValue;
this.ok_status = ok_status;

View File

@ -13,9 +13,6 @@ public class StopErrorHandler implements ErrorHandler {
@Override
public ErrorDetail handleError(Throwable t, long cycle, long durationInNanos, ErrorDetail detail) {
String durationSummary = String.format("%.3fS", ((double) durationInNanos / 1000000000.0));
throw new RuntimeException(
"An error was rethrown in order to stop the activity in cycle:" + cycle + ", duration:" + durationSummary + " msg:" +
t.getMessage());
throw new RuntimeException(t);
}
}