[Pkg-javascript-commits] [ltx] 117/469: stream_parser: with error conditions

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:01:11 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit bb7a9a43b9020477786404ff1780a0daf2e85888
Author: Astro <astro at spaceboyz.net>
Date:   Thu Sep 9 01:39:24 2010 +0200

    stream_parser: with error conditions
---
 lib/xmpp/connection.js    | 5 +----
 lib/xmpp/stream_parser.js | 7 ++++---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/xmpp/connection.js b/lib/xmpp/connection.js
index 05a4651..49aa5f1 100644
--- a/lib/xmpp/connection.js
+++ b/lib/xmpp/connection.js
@@ -90,10 +90,7 @@ Connection.prototype.startParser = function() {
 	self.onStanza(self.addStreamNs(stanza));
     });
     this.parser.addListener('error', function(e) {
-	if (e.message)
-	    self.error(e.message);
-	else
-	    self.error('internal-server-error', e.toString());
+	self.error(e.condition || 'internal-server-error', e.message);
     });
     this.parser.addListener('end', function() {
 	self.end();
diff --git a/lib/xmpp/stream_parser.js b/lib/xmpp/stream_parser.js
index 4d788d1..a731075 100644
--- a/lib/xmpp/stream_parser.js
+++ b/lib/xmpp/stream_parser.js
@@ -74,7 +74,8 @@ StreamParser.prototype.end = function(data) {
     this.emit('end');
 };
 
-// TODO: support error condition & text
-StreamParser.prototype.error = function(reason) {
-    this.emit('error', new Error(reason));
+StreamParser.prototype.error = function(condition, message) {
+    var e = new Error(reason);
+    e.condition = condition;
+    this.emit('error', e);
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list