Skip to content

Commit

Permalink
Gracefully report attempt errors detected during token parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pekim committed Nov 22, 2011
1 parent 8e6b415 commit 1af0fd0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/connection.coffee
Expand Up @@ -80,6 +80,7 @@ class Connection extends EventEmitter
@connection.destroy()

eventTimeout: =>
@emit('timeout')
@fatalError('timeout')
@connection.destroy()

Expand Down Expand Up @@ -148,6 +149,9 @@ class Connection extends EventEmitter
@tokenStreamParser.on('returnStatus', (token) =>
@procReturnStatusValue = token.value
)
@tokenStreamParser.on('error', (token) =>
@fatalError(token.error)
)
@tokenStreamParser.on('done', (token) =>
state = @state

Expand Down
2 changes: 1 addition & 1 deletion lib/debug.coffee
Expand Up @@ -15,7 +15,7 @@ class Debug extends EventEmitter
@indent = ' '

packet: (direction, packet) ->
if @haveListeners()
if @haveListeners() && @options.packet
@log('')
@log(direction)
@log(packet.headerToString(@indent))
Expand Down
1 change: 1 addition & 0 deletions lib/token/token-stream-parser.coffee
Expand Up @@ -65,6 +65,7 @@ class Parser extends EventEmitter

true
else
@emit('error', token)
false
else
false
Expand Down

0 comments on commit 1af0fd0

Please sign in to comment.