Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect "No such file or directory" error? #32

Open
wf9a5m75 opened this issue Sep 18, 2015 · 2 comments
Open

How to detect "No such file or directory" error? #32

wf9a5m75 opened this issue Sep 18, 2015 · 2 comments

Comments

@wf9a5m75
Copy link

Hi, could you tell me how to catch the "No such file or directory" error?

var base64 = require('base64-stream');

client.pull(device.id, '/sdcard/mydata.txt')
  .then(function(transfer) {
     transfer.pipe(base64.decode()).pipe(process.stdout)
  })
  .catch(function(error) {
    console.log('-----> error');  // <-- This does not work.
  });
@wf9a5m75
Copy link
Author

I also tried using callback, but I could not catch the error.

client.pull(device.id, '/sdcard/mydata.txt', function(err) {
    console.log(err);  // <-- This output is "null", but 'No such file or directory' error occurs.
} );

@wf9a5m75
Copy link
Author

I figured out finally, but please tell me if there is more any better way.

  client.syncService(device.id).
      then(function(sync) {
        sync.pull( '/sdcard/mydata.txt')
        .on('error', function(err) {
          console.log("---> error");
          console.log(err);
        })
        .on('end', function() {
          sync.end();
        })
        .pipe(process.stdout);
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant