From b57d7d9b4e0caf7b7232957695383f195aad258a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Wed, 20 Jan 2010 13:38:37 +0100 Subject: [PATCH] Treat 'typeof Error' promise errors properly Instead of JSON encoding them, just rethrow promise errors since that produces much cleaner error messages. --- src/node.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 725291c442..6cf17c1445 100644 --- a/src/node.js +++ b/src/node.js @@ -294,7 +294,9 @@ var eventsModule = createInternalModule('events', function (exports) { var self = this; process.nextTick(function() { if (self.listeners('error').length == 0) { - throw new Error('Unhandled emitError: '+JSON.stringify(self._values)); + throw (self._values[0] instanceof Error) + ? self._values[0] + : new Error('Unhandled emitError: '+JSON.stringify(self._values)); } }); }