From 36d483806f0897e3866e8b17913ff8de05e3e6bd Mon Sep 17 00:00:00 2001 From: irond13 Date: Fri, 7 Aug 2015 16:43:57 +0200 Subject: [PATCH] Made sure not to overwrite original error context This happens in the case of uncaught errors in nested contexts (which are sometimes created by Mongoose, etc). The nested context rethrows the error in its catch block after attaching itself to the error, which is then subsequently caught by the parent context. Without my change the originating context would be overwritten on the error. This makes Namespace.prototype.fromException useless in such cases. --- context.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context.js b/context.js index 659f837..9c5761a 100644 --- a/context.js +++ b/context.js @@ -49,7 +49,7 @@ Namespace.prototype.run = function (fn) { return context; } catch (exception) { - exception[ERROR_SYMBOL] = context; + if(! exception[ERROR_SYMBOL]) exception[ERROR_SYMBOL] = context; throw exception; } finally { @@ -74,7 +74,7 @@ Namespace.prototype.bind = function (fn, context) { return fn.apply(this, arguments); } catch (exception) { - exception[ERROR_SYMBOL] = context; + if(! exception[ERROR_SYMBOL]) exception[ERROR_SYMBOL] = context; throw exception; } finally {