我需要在错误处理中捕获 StackTrace 。我在 chrome 中收到此错误。我在 Angular 4 中传回来自http的响应时得到它。我该如何处理?
private myErrorHandleFunction(error: any) {
console.log(new Error(error).stack);
const callback = (stackframes) => {
const stringifiedStack = stackframes.map(function (sf) {
return sf.toString();
}).join('\n');
this.logService();
const errback = (error: any) => {
console.log(new Error('from onerror').stack);
};
StackTrace.fromError(new Error(error).stack).then(callback).catch(errback);
} };
//输出
Error: Error: Cannot parse given Error object
at a (error-handler.ts:62)
at t.invoke (zone.js:391)
at Object.onInvoke (ng_zone.ts:291)
at t.invoke (zone.js:390)
at r.run (zone.js:141)
at zone.js:832
at t.invokeTask (zone.js:424)
at Object.onInvokeTask (ng_zone.ts:280)
at t.invokeTask (zone.js:423)
at r.runTask (zone.js:191)