Skip to content

Commit

Permalink
Merge pull request #17 from SaltwaterC/master
Browse files Browse the repository at this point in the history
Emits an error even for the sax event onerror
  • Loading branch information
Leonidas-from-XIV committed Jun 23, 2011
2 parents 726397c + a48e4a4 commit c0e8a01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/xml2js.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/xml2js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ class exports.Parser extends events.EventEmitter
trim: false,
normalize: false
}

# emit one error event if the sax parser fails. this is mostly a hack, but
# the sax parser isn't state of the art either.
err = false
@saxParser.onerror = (error) =>
if ! err
err = true
@emit "error", error

# always use the '#' key, even if there are no subkeys
# setting this property by and is deprecated, yet still supported.
# better pass it as explicitCharkey option to the constructor
Expand Down

0 comments on commit c0e8a01

Please sign in to comment.