Przeglądaj źródła

fix #2694 return response body

Shinsuke Sugaya 2 lat temu
rodzic
commit
3eeb8cb839

+ 3 - 3
src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessApiFailureHook.java

@@ -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(" "));
         }