From b547be44b2bc1a54841a0ea17a7fbdb9bbac3939 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 1 Dec 2014 14:53:03 -0500 Subject: [PATCH] Better error message output --- .../discourse/routes/application.js.es6 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/routes/application.js.es6 b/app/assets/javascripts/discourse/routes/application.js.es6 index 794448f8d17..ca598b77489 100644 --- a/app/assets/javascripts/discourse/routes/application.js.es6 +++ b/app/assets/javascripts/discourse/routes/application.js.es6 @@ -27,10 +27,16 @@ var ApplicationRoute = Discourse.Route.extend({ } var exceptionController = this.controllerFor('exception'), - errorString = err.toString(); - if (err.statusText) { - errorString = err.statusText; - } + errorString = err.toString(), + stack = err.stack; + + // If we have a stack call `toString` on it. It gives us a better + // stack trace since `console.error` uses the stack track of this + // error callback rather than the original error. + if (stack) { errorString = stack.toString(); } + + if (err.statusText) { errorString = err.statusText; } + var c = window.console; if (c && c.error) { c.error(errorString);