bug 5482: Fixed malformed JSON when an error is returned by the API call. Also fixed the UI to make use of the new JSON object.

This commit is contained in:
will 2011-01-05 18:06:48 -08:00
parent 3992d122ff
commit 68d5c0919a
2 changed files with 6 additions and 5 deletions

View File

@ -64,7 +64,7 @@ public class ApiResponseSerializer {
} else if (result instanceof SuccessResponse) {
sb.append("{ \"success\" : \""+((SuccessResponse)result).getSuccess()+"\"} ");
} else if (result instanceof ExceptionResponse) {
sb.append("{\"errorcode\" : \""+((ExceptionResponse)result).getErrorCode() + ", \"errortext\" : \""+ ((ExceptionResponse)result).getErrorText() +"\"} ");
sb.append("{\"errorcode\" : "+((ExceptionResponse)result).getErrorCode() + ", \"errortext\" : \""+ ((ExceptionResponse)result).getErrorText() +"\"} ");
}else {
String jsonStr = gson.toJson(result);
if ((jsonStr != null) && !"".equals(jsonStr)) {

View File

@ -1073,10 +1073,11 @@ function handleErrorInDialog2(errorMsg, $thisDialog) {
}
function parseXMLHttpResponse(XMLHttpResponse) {
var start = XMLHttpResponse.responseText.indexOf("h1") + 3;
var end = XMLHttpResponse.responseText.indexOf("</h1");
var errorMsg = XMLHttpResponse.responseText.substring(start, end);
return fromdb(errorMsg);
var property;
var json = jQuery.parseJSON(XMLHttpResponse.responseText);
for(property in json) {}
var errorObj = json[property];
return fromdb(errorObj.errortext);
}
function showLeftNavigationBasedOnRole() {