1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

Include PR Feedback: Check if Error.captureStackTrace is available

This commit is contained in:
Tim Daubenschütz 2015-12-07 11:30:45 +01:00
parent 4f39103baf
commit 0a67766aba
2 changed files with 8 additions and 2 deletions

View File

@ -4,7 +4,8 @@ import invariant from 'invariant';
const ReactError = {
throws(err) {
invariant(err.handler, 'You need to specify a `handler` for this error');
invariant(err.handler, 'Error thrown to ReactError did not have a `handler` function');
console.logGlobal('Error thrown to ReactError did not have a `handler` function');
err.handler(this, err);
}
};

View File

@ -10,7 +10,12 @@ export class ResourceNotFoundError extends Error {
super(message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor.name);
// `captureStackTrace` might not be available in IE:
// - http://stackoverflow.com/a/8460753/1263876
if(Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor.name);
}
}
handler(component, err) {