Fixed exception handling for minimize json.

This commit is contained in:
2023-03-01 16:14:11 +01:00
parent 5042e48e5c
commit 3dee4c1f1a

View File

@@ -28,7 +28,6 @@ public class JsonController implements RestController {
JsonObject jsonObject = this.gson.fromJson(request.body(), JsonObject.class);
response.status(200);
response.body(this.prettyGson.toJson(jsonObject));
System.out.printf(response.body());
} catch (Exception e) {
response.status(500);
Throwable cause = e.getCause();
@@ -37,7 +36,6 @@ public class JsonController implements RestController {
} else {
response.body(cause.getMessage());
}
System.out.printf(response.body());
}
}
@@ -49,7 +47,12 @@ public class JsonController implements RestController {
response.body(this.gson.toJson(jsonObject));
} catch (Exception e) {
response.status(500);
Throwable cause = e.getCause();
if (cause == null) {
response.body(e.getMessage());
} else {
response.body(cause.getMessage());
}
}
}
}