Skip to content

how do you handle errors here #6

Open

Description

@nichoth
function createMyStream (emitter) {
    var pushable = Pushable((err) => console.log('error', err))
    emitter.on('data', pushable.push.bind(pushable))
    emitter.on('end', pushable.end.bind(pushable))
    emitter.on('error', ???)
    return pushable
}

thanks

Activity

  1. dominictarr commented on Aug 21, 2016

    @dominictarr
    Member

    pushable.end takes an argument, https://github.com/pull-stream/pull-pushable/blob/master/index.js#L28 that can be the error,

    but really, it looks like you should use stream-to-pull-stream instead of pull-pushable

    return toPull.source(emitter)

  2. nichoth commented on Aug 21, 2016

    @nichoth
    Author

    Ah ha. So pushable.end() can be the end event, and pushable.end(error) can be the error event. Thanks

    function createMyStream (emitter) {
        var pushable = Pushable(function onEnd (err) {
            if (err) console.log(err)
            emitter.removeAllListeners()
        })
        emitter.on('data', (data) => pushable.push(data))
        emitter.on('end', () => pushable.end())
        emitter.on('error', (err) => pushable.end(err))
        return pushable
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions