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

skip question when error in choices function #832

Open
GiladShoham opened this issue Aug 1, 2019 · 3 comments
Open

skip question when error in choices function #832

GiladShoham opened this issue Aug 1, 2019 · 3 comments

Comments

@GiladShoham
Copy link

Hi,

I have a question with choices as function.
This function fetches answers from a remote server which might be unavailable or the query to the remote is invalid.
This question is part of a qustions array.
I want to catch an error in the function of the choice (not a problem), write it to the user. and skip the question and moving to the next one.
I can put the check in the when, but it's a time-consuming check and I don't want to do it twice both in when and in choices.
Is there any way to handle this? or just by opt-out from the array way of prompting?

Thanks.

@SBoudrias
Copy link
Owner

How about you do this processing before calling inquirer.prompt()?

@GiladShoham
Copy link
Author

I can't do it before because the choices are based on previous answers.
I ended up putting the logic of the choices inside the when and if there was an error I returned false. If it worked I just store the choices in a var and just use it in the choices.
You can see the full code here:
https://github.com/teambit/bit/blob/master/src/interactive/commands/init-interactive.js#L51
It was great if I would have an API like this.skip function inside the choices function.

@Aid19801
Copy link

Aid19801 commented Mar 2, 2020

@GiladShoham "page not found"

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

3 participants