From 0a67766abaf9e71f9278695976253e560504c3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Mon, 7 Dec 2015 11:30:45 +0100 Subject: [PATCH] Include PR Feedback: Check if Error.captureStackTrace is available --- js/mixins/react_error.js | 3 ++- js/models/errors.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/js/mixins/react_error.js b/js/mixins/react_error.js index 0b7669de..1169a069 100644 --- a/js/mixins/react_error.js +++ b/js/mixins/react_error.js @@ -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); } }; diff --git a/js/models/errors.js b/js/models/errors.js index d7843d30..e748d953 100644 --- a/js/models/errors.js +++ b/js/models/errors.js @@ -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) {