Permalink
Browse files

Merge pull request #5 from andris9/master

Eternal loop with error emitter
  • Loading branch information...
2 parents 860a504 + 77adfa0 commit e8741a5eec45e695b7c06dfb4dfa458b50d33047 @Zoramite Zoramite committed Jul 29, 2012
Showing with 19 additions and 1 deletion.
  1. +1 −1 lib/xml2object.js
  2. +17 −0 test/error-test.js
  3. +1 −0 test/fixture/input02.xml
View
@@ -140,7 +140,7 @@ var xml2object = module.exports = function(elements, source) {
// Rebroadcast the error and keep going
this.saxStream.on("error", function (e) {
- this.emit('error', e);
+ self.emit('error', e);
// clear the error and resume
this._parser.error = null;
View
@@ -0,0 +1,17 @@
+var nodeunit = require('nodeunit');
+var path = require('path');
+var xml2object = require('../lib/xml2object');
+
+exports.testError = function(test){
+ test.expect(1);
+
+ var parser = new xml2object(['dog'], path.normalize(__dirname + '/fixture/input02.xml'));
+ var found = [];
+
+ parser.on('error', function(error) {
+ test.ok(error instanceof Error);
+ test.done();
+ });
+
+ parser.start();
+};
@@ -0,0 +1 @@
+just some invalid xml data

0 comments on commit e8741a5

Please sign in to comment.