fix #2694 return response body

This commit is contained in:
Shinsuke Sugaya 2022-10-24 20:27:20 +09:00
parent 84355e91cb
commit 3eeb8cb839

View file

@ -59,12 +59,12 @@ public class FessApiFailureHook implements ApiFailureHook { // #change_it for ha
// ==============
@Override
public OptionalThing<ApiResponse> handleClientException(final ApiFailureResource resource, final RuntimeException cause) {
return OptionalThing.empty(); // means empty body (HTTP status will be automatically sent)
return OptionalThing.of(asJson(createFailureBean(Status.BAD_REQUEST, createMessage(resource, cause))));
}
@Override
public OptionalThing<ApiResponse> handleServerException(final ApiFailureResource resource, final Throwable cause) {
return OptionalThing.empty(); // means empty body (HTTP status will be automatically sent)
return OptionalThing.of(asJson(createFailureBean(Status.SYSTEM_ERROR, createMessage(resource, cause))));
}
// ===================================================================================
@ -78,7 +78,7 @@ public class FessApiFailureHook implements ApiFailureHook { // #change_it for ha
return new ApiErrorResponse().message(message).status(status).result();
}
protected String createMessage(final ApiFailureResource resource, final RuntimeException cause) {
protected String createMessage(final ApiFailureResource resource, final Throwable cause) {
if (!resource.getMessageList().isEmpty()) {
return resource.getMessageList().stream().collect(Collectors.joining(" "));
}