From 601b2537ec48faa28f948dcbc1f2a7912fdc8242 Mon Sep 17 00:00:00 2001 From: Pelle Mattsson Date: Mon, 3 Jul 2017 10:51:57 +0200 Subject: [PATCH] Try to stringify message errors so socket errors keep their data. (#386) --- src/message/connection.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/message/connection.js b/src/message/connection.js index 4ce514821..d0e809d35 100644 --- a/src/message/connection.js +++ b/src/message/connection.js @@ -320,7 +320,11 @@ Connection.prototype._onError = function (error) { if (error.code === 'ECONNRESET' || error.code === 'ECONNREFUSED') { msg = `Can't connect! Deepstream server unreachable on ${this._originalUrl}` } else { - msg = error.toString() + try { + msg = JSON.stringify(error) + } catch(e) { + msg = error.toString() + } } this._client._$onError(C.TOPIC.CONNECTION, C.EVENT.CONNECTION_ERROR, msg) }, 1)