noodny / node-ftp-client

MIT License
64 stars 32 forks source link

bug fix for Client.js #20

Open vagishdwivedi opened 6 years ago

vagishdwivedi commented 6 years ago

throwing error causes whole program to terminate as there's no way to catch it. If you return this error, client program can listen it like: client.ftp.on('error', callback) and act accordingly. Example:

    client.connect(function() {
      console.log('connected to client');
      client.upload(request.body.fileName, request.body.uploadPath, {
            overwrite: 'older'
        }, function(result) {
        console.log(result);

        response.status(200).json(result);
      });
    });

    client.ftp.on('error', function(err) {
      console.log('--- client error: ', err);
    });
vagishdwivedi commented 6 years ago

@noodny do you think it should be merged? Throwing error causes whole App to break, if we return then consumer app can handle it robustly.