From 8dbddcbf922454fc061318df12c6381e812fff55 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Sat, 24 Jan 2015 00:01:48 -0800 Subject: [PATCH] display APIException errors properly --- planetstack/core/xoslib/static/js/xoslib/xosHelper.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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)})) -- 2.43.0