Skip to content

Commit

Permalink
reduce surface of the exception handler in SyncTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypopp committed Apr 2, 2013
1 parent 333099f commit f89fa4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions ws-chan.coffee
Expand Up @@ -14,10 +14,11 @@ class SyncTransform extends Transform

_transform: (chunk, encoding, cb) ->
try
this.push(if this.fn? then this.fn(chunk) else chunk)
cb()
transformed = if this.fn? then this.fn(chunk) else chunk
catch e
cb(e)
return cb(e)
this.push(transformed)
cb()

class Channel extends EventEmitter

Expand Down
7 changes: 4 additions & 3 deletions ws-chan.js

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

0 comments on commit f89fa4a

Please sign in to comment.