Skip to content

Commit

Permalink
merge with better exception serialzation
Browse files Browse the repository at this point in the history
  • Loading branch information
skovati committed Nov 13, 2023
1 parent 32898c4 commit a993b7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,21 @@ public static JsonValue serializeBulkArgumentValidationResponse(BulkArgumentVali
return Json.createObjectBuilder(serializeInstantiationException(f.ex()).asJsonObject())
.add("type", "INSTANTIATION_ERRORS")
.build();
} else if (response instanceof BulkArgumentValidationResponse.RuntimeError e) {
} else if (response instanceof BulkArgumentValidationResponse.RuntimeException e) {
return Json.createObjectBuilder()
.add("success", JsonValue.FALSE)
.add("type", "RUNTIME_EXCEPTION")
.add("errors", Json.createArrayBuilder()
.add(e.t().getMessage())
.add("errors", Json.createObjectBuilder()
.add("runtimeException", e.t().getMessage())
.build())
.build();
}

// This should never happen, but we don't have exhaustive pattern matching
return Json.createObjectBuilder()
.add("success", JsonValue.FALSE)
.add("errors", Json.createArrayBuilder()
.add(String.format("Internal error: %s", response))
.add("errors", Json.createObjectBuilder()
.add("internalError", response.toString())
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public List<BulkArgumentValidationResponse> validateActivityArgumentsBulk(
} catch (InstantiationException e) {
return new BulkArgumentValidationResponse.InstantiationError(e);
} catch (Throwable t) {
return new BulkArgumentValidationResponse.RuntimeError(t);
return new BulkArgumentValidationResponse.RuntimeException(t);
}
}).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,6 @@ record Success() implements BulkArgumentValidationResponse { }
record Validation(List<ValidationNotice> notices) implements BulkArgumentValidationResponse { }
record NoSuchActivityError(NoSuchActivityTypeException ex) implements BulkArgumentValidationResponse { }
record InstantiationError(InstantiationException ex) implements BulkArgumentValidationResponse { }
record RuntimeError(Throwable t) implements BulkArgumentValidationResponse { }
record RuntimeException(Throwable t) implements BulkArgumentValidationResponse { }
}
}

0 comments on commit a993b7f

Please sign in to comment.