From: Scott Baker Date: Sat, 24 Jan 2015 08:01:48 +0000 (-0800) Subject: display APIException errors properly X-Git-Url: http://git.onelab.eu/?p=plstackapi.git;a=commitdiff_plain;h=8dbddcbf922454fc061318df12c6381e812fff55 display APIException errors properly --- diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js index 384a7ed..9f5eadf 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js +++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js @@ -147,7 +147,15 @@ XOSApplication = Marionette.Application.extend({ } console.log(responseText); console.log(parsed_error); - if (parsed_error) { + + if (parsed_error && ("error" in parsed_error)) { + // this error comes from genapi views + $("#xos-error-dialog").html(templateFromId("#xos-error-response")(parsed_error)); + } else if (parsed_error && ("detail" in parsed_error)) { + // this error response comes from rest_framework APIException + parsed_error["error"] = "API Error"; + parsed_error["specific_error"] = parsed_error["detail"]; + parsed_error["reasons"] = []; $("#xos-error-dialog").html(templateFromId("#xos-error-response")(parsed_error)); } else { $("#xos-error-dialog").html(templateFromId("#xos-error-rawresponse")({responseText: strip_scripts(responseText)}))