0
我正在使用角拦截器,并且我想从500个错误(内部服务器错误)中获取消息。角拦截器 - 从500错误中获取消息
的问题是,我得到的rejection.data整个HTML中responseError内拦截器(下图)。
我读过,我必须配置web.config但我仍然得到整个HTML。我只想得到消息。
有没有可能这样做?
角拦截:
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push(function ($q, $rootScope) {
return {
request: function (config) {
//the same config/modified config/a new config needs to be returned.
return config;
},
requestError: function (rejection) {
//Initializing error list
if ($rootScope.errorList == undefined) {
$rootScope.errorList = [];
}
$rootScope.errorList.push(rejection.data);
//It has to return the rejection, simple reject call doesn't work
return $q.reject(rejection);
},
response: function (response) {
//the same response/modified/or a new one need to be returned.
return response;
},
responseError: function (rejection) {
//Initializing the error list
if ($rootScope.errorList == undefined) {
$rootScope.errorList = [];
}
//Adding to error list
$rootScope.errorList.push(rejection.data);
//It has to return the rejection, simple reject call doesn't work
return $q.reject(rejection);
}
};
});
}]);
的Web.Config
<system.webServer>
<httpErrors existingResponse="PassThrough" errorMode="Detailed"></httpErrors>
</system.webServer>
编辑: 我想从异常快照消息
你这是在data.message得到些什么? – Disha
什么都没有。因为在数据中我有像第一张图片那样的整个HTML。我做了一个编辑 - 看看。 –