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