Commit a5f0f508 by Torkel Ödegaard

feat(inspector): fixed error handling, showing response body when data proxy returns text/html body

parent 58df60f6
...@@ -7,7 +7,7 @@ define([ ...@@ -7,7 +7,7 @@ define([
function (angular, _, $, coreModule) { function (angular, _, $, coreModule) {
'use strict'; 'use strict';
coreModule.default.controller('InspectCtrl', function($scope) { coreModule.default.controller('InspectCtrl', function($scope, $sanitize) {
var model = $scope.inspector; var model = $scope.inspector;
function getParametersFromQueryString(queryString) { function getParametersFromQueryString(queryString) {
...@@ -32,7 +32,11 @@ function (angular, _, $, coreModule) { ...@@ -32,7 +32,11 @@ function (angular, _, $, coreModule) {
if (_.isString(model.error.data)) { if (_.isString(model.error.data)) {
$scope.response = $("<div>" + model.error.data + "</div>").text(); $scope.response = $("<div>" + model.error.data + "</div>").text();
} else if (model.error.data) { } else if (model.error.data) {
$scope.response = angular.toJson(model.error.data, true); if (model.error.data.response) {
$scope.response = $sanitize(model.error.data.response);
} else {
$scope.response = angular.toJson(model.error.data, true);
}
} else if (model.error.message) { } else if (model.error.message) {
$scope.message = model.error.message; $scope.message = model.error.message;
} }
......
...@@ -138,7 +138,8 @@ export class BackendSrv { ...@@ -138,7 +138,8 @@ export class BackendSrv {
//populate error obj on Internal Error //populate error obj on Internal Error
if (_.isString(err.data) && err.status === 500) { if (_.isString(err.data) && err.status === 500) {
err.data = { err.data = {
error: err.statusText error: err.statusText,
response: err.data,
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment