use of org.talend.sdk.component.form.model.UiActionResult in project component-runtime by Talend.
the class ActionService method map.
public UiActionResult map(final WebException exception) {
final UiActionResult actionResult = new UiActionResult();
actionResult.setRawData(exception.getData());
// default error will be mapped to the calling option
actionResult.setError(ofNullable(exception.getData()).flatMap(d -> Stream.of("description", "comment").map(d::get).filter(Objects::nonNull).findFirst()).map(String::valueOf).orElse(exception.getMessage()));
return actionResult;
}
use of org.talend.sdk.component.form.model.UiActionResult in project component-runtime by Talend.
the class WebAppComponentProxy method onException.
private void onException(final AsyncResponse response, final Throwable e) {
final UiActionResult payload;
final int status;
if (WebException.class.isInstance(e)) {
final WebException we = WebException.class.cast(e);
status = we.getStatus();
payload = actionService.map(we);
} else if (CompletionException.class.isInstance(e)) {
final CompletionException actualException = CompletionException.class.cast(e);
log.error(actualException.getMessage(), actualException);
status = Response.Status.BAD_GATEWAY.getStatusCode();
payload = actionService.map(new WebException(actualException, -1, emptyMap()));
} else {
log.error(e.getMessage(), e);
status = Response.Status.BAD_GATEWAY.getStatusCode();
payload = actionService.map(new WebException(e, -1, emptyMap()));
}
response.resume(new WebApplicationException(Response.status(status).entity(payload).build()));
}
Aggregations