我已经将 airbrake 配置为报告错误,但它似乎没有报告 http 错误。因此,我正在尝试将其配置为这样做。这是我的工厂:
import AirbrakeClient from 'airbrake-js';
export let errorHttpInterceptor = ($q, CONSTANT) => {
'use strict';
let airbrake = new AirbrakeClient({
projectId: CONSTANTS.AIRBRAKE_PROJECT_ID,,
projectKey: CONSTANTS.AIRBRAKE_PROJECT_KEY
});
airbrake.addFilter((notice) => {
console.log(notice);
return notice;
});
return {
requestError: (rejection) => {
console.log(rejection);
// do something on error
airbrake.notify(rejection);
return $q.reject(rejection);
},
responseError: (rejection) => {
console.log(rejection);
airbrake.notify(rejection);
return $q.reject(rejection);
}
};
};
然后在配置中:
let httpAuthConfig = /*@ngInject*/ $httpProvider => {
'use strict';
let errorHttp = $injector => { return $injector.get('errorHttpInterceptor'); };
$httpProvider.interceptors.push(['$injector', errorHttp]);
};
它似乎只在我得到[object Object]
空气制动错误时起作用,没有额外的错误细节或回溯。还有什么我想念的吗?