diff --git a/src/message/connection.js b/src/message/connection.js index 98f03a27d..9953d94bd 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)