'Angular2/Angular4 : Cannot parse given Error object - StackTrace JS

I need to catch a StackTrace in my error handling. I'm getting this error in chrome. I am getting it when passing back a Response from http in Angular 4. How will I handle it?

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);

} };

// Output

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)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source