private static JSONObject createResponseContent(EMFAbstractError error) throws JSONException { JSONObject jsonObject = new JSONObject(); if (error instanceof EMFInternalError) { EMFInternalError internalError = (EMFInternalError) error; Exception e = internalError.getNativeException(); if (e != null && e instanceof SpagoBIServiceException) { SpagoBIServiceException serviceError = (SpagoBIServiceException) e; jsonObject = createResponseContent(serviceError); } else { jsonObject = createResponseContent(internalError); } } else if (error instanceof EMFUserError) { EMFUserError userError = (EMFUserError) error; if (userError instanceof EMFValidationError) { EMFValidationError validationError = (EMFValidationError) error; jsonObject = createResponseContent(validationError); } else { jsonObject = createResponseContent(userError); } } else { jsonObject = new JSONObject(); jsonObject.put("severity", error.getSeverity()); jsonObject.put("message", error.getMessage()); jsonObject.put("localizedMessage", error.getDescription()); } return jsonObject; }