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。我做了一個編輯 - 看看。 –