Fixed exception handling for minimize json.
This commit is contained in:
@@ -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);
|
||||
response.body(e.getMessage());
|
||||
Throwable cause = e.getCause();
|
||||
if (cause == null) {
|
||||
response.body(e.getMessage());
|
||||
} else {
|
||||
response.body(cause.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user