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

Handling errors #74

Closed
pablopunk opened this issue Apr 11, 2017 · 3 comments
Closed

Handling errors #74

pablopunk opened this issue Apr 11, 2017 · 3 comments
Labels

Comments

@pablopunk
Copy link

What is the best way to handle errors? For example if I got the following code:

var pty = require('node-pty');
var shell = 'wrongshell'
var ptyProcess = pty.spawn(shell, [], options);

ptyProcess.on('data', function(data) {
  console.log(data);
});

The line console.log(data) is gonna print execvp(3) failed.: No such file or directory because the shell wrongshell doesn't exist.

Is it better to check if the shell exists before initializing pty? Or is there any error handling built in to handle this type of errors?

@Tyriar
Copy link
Member

Tyriar commented Apr 18, 2017

I guess it's up to you and your application, you may have difficulty checking whether wrongshell exists though as you'll need to check the $PATH (and also source .bashrc/.zshrc etc. as appropriate).

For VS Code we just output it in the panel but then immediately close the panel and show the exit code of the shell process. It's a pretty bad experience right now but it's better than doing nothing.

@pablopunk
Copy link
Author

@Tyriar yeah actually I needed this to resolve this issue, cause right now the window is just being closed without any notice. I guess the best will be displaying a warning or something like that.

@Tyriar
Copy link
Member

Tyriar commented Apr 20, 2017

Very similar to the VS Code problem, right now I listen to see if the terminal exits within 500ms of launching and if so, I assume it crashed due to the config. Not perfect but a good stop gap solution until something better is implemented.

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

No branches or pull requests

2 participants