Ejemplo n.º 1
0
  @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);
    }
  }
Ejemplo n.º 2
0
  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()));
    }
  }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 @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);
 }