Open toonborgers opened 6 years ago
I am seeing this as well. Interested in the proper way to workaround this or handle it.
For now, I'm just not sending these Errors to stacktrace.js:
// Don't try to send stacktraces of HTTP errors as they are already logged on the server
// and they cause stacktrace-js to throw an exception.
if (!error.url && !error.headers) {
// get the stack trace
StackTrace.fromError(error).then(stackframes => {
...
}
}
With ExtJS i had the same problem.
This should be because in chrome user defined exceptions dont have a stacktrace by default. As there is nothing to parse stacktrace.js
throws an error. To get a stacktrace in user definedexceptions you have to use the V8 STacktrace API; see: Error.captureStackTrace().
Example with standard javascript:
function MyError(message) {
this.message = message;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CustomError);
} else {
this.stack = (new Error).stack;
}
}
MyError.prototype = Object.create(Error.prototype);
MyError.prototype.name = "MyError";
For ExtJS i just overwritten the constructor of the default exception.
@JoeScylla not sure about this, but according to this new Error().stack
should be always undefined for a couple of browsers.
I'm creating an Angular5 app with Typescript and was trying to add stacktrace-js for proper error handling.
When I was testing my setup using a failing http request (404 response), I get an error from stacktrace-js that the error can't be parsed.
Expected Behavior
The error can be parsed correctly.
Current Behavior
The error can't be parsed.
Steps to Reproduce (for bugs)
Set up an environment as in following gist and start the dev server. When the component does the request and it fails, the error handler gets triggered and the described behaviour occurs.
Gist
Context
I was trying to setup error handling for an angular app
Your Environment