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 #152

Open
N1ark opened this issue Jul 15, 2023 · 3 comments
Open

Handling errors #152

N1ark opened this issue Jul 15, 2023 · 3 comments

Comments

@N1ark
Copy link

N1ark commented Jul 15, 2023

I've been using the plugin, and noticed that it doesn't seem possible to properly catch errors thrown within the source async function to allow for a graceful exit with this.error if something goes wrong. No error message is printed either, and calling this.error inside the async function doesn't work either.

Is there something I missed?

Example code:

try {
  await inquirer
    .prompt([
      {
        type: "autocomplete",
        name: "test",
        message: "Will quit",
        source: async () => { throw Error() },
      },
    ])
    .catch(() => console.log("This is never printed"));
} finally {
  console.log("This is never printed");
}
@mokkabonna
Copy link
Owner

Yeah that should have been handled better. In the newer inquirer-autocomplete-standalone package it is handled and presented as an error if it fails.

image

@mokkabonna
Copy link
Owner

Not sure why I never implemented that, I guess I never had the problem myself so forgot/ignored, and nobody else mentioned it either until now :)

@N1ark
Copy link
Author

N1ark commented Dec 12, 2023

Nice ! Yeah understandable hahah, thanks for implementing it :D

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

2 participants