@Override public Result onError(RequestHeader request, Throwable t) { AccessLogger.log(request, null, Http.Status.INTERNAL_SERVER_ERROR); if (Play.isProd()) { return Results.internalServerError( views.html.error.internalServerError_default.render("error.internalServerError")); } else { return super.onError(request, t); } }
public static Result addThirdParty() { AppUtils.setHeaders(response()); try { ThirdParty thirdParty = Form.form(ThirdParty.class).bindFromRequest().get(); thirdParty.save(); return Results.ok(Json.toJson(thirdParty)); } catch (Exception e) { e.printStackTrace(); return Results.internalServerError(AppUtils.errorJsonResponse(e.getMessage())); } }
public static Result toResult(RuntimeException re) { Logger.error("ERROR: ", re); String msg = re.getMessage(); if (msg == null) { // api doesn't allow null strings msg = ""; } re.printStackTrace(); if (re instanceof NotFoundException) { return Results.notFound(msg); } else if (re instanceof ForbiddenException) { return Results.forbidden(msg); } else if (re instanceof IllegalStateException || re instanceof IllegalArgumentException || re instanceof UnsupportedOperationException || re instanceof PersistenceException) { return Results.badRequest(re.getMessage()); } return Results.internalServerError(msg); }
@Override public Result onError(RequestHeader h, Throwable t) { if (Play.application().isProd()) return Results.internalServerError(JapidController.renderJapidWith("onError.html", h, t)); else return super.onError(h, t); }