-
-
Notifications
You must be signed in to change notification settings - Fork 71
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 is error handling supposed to work? #89
Comments
Hey @tyrsius, it is very hard to see what is the issue you're running into. Usually errors aren't swallowed and exposed properly to the user; so you're definitely not hitting the desired/default behavior . As such, I can't help you find/fix the bug unless you provide a more complete example. Can you provide the exact code and steps to reproduce your issue? |
Sure. Ive got a generator that composes other generators.
And a runner that kicks it off
If any of the composed generators throws errors in their normal functions, like |
@SBoudrias ☝️ |
@tyrsius so if I understand this properly; only errors thrown inside composed generators are not being catch? |
Yes. |
Okay, this looks like a valid bug. I don't think I'll have much time to dig into it in the next week. But let me know if I can help you prepare a PR to fix that! |
This should be an easy fix - just register the error event of created generators and emit error on the environment itself. const generator = env.create(generatorName, { args: [], options: {} });
if (generator instanceof Error) {
return onError(generator);
}
generator.on('error', onError);
generator.run((err) => {
// error was handled already in the event handler above
if (!err){
console.log('Finished generating');
resolve();
}
}); |
@regevbr want to send a PR for this one? Looks like you got it figured out |
@SBoudrias sure ill give it a go |
When running yeoman environment errors in generators get swallowed. I've trying using
env.on('error')
to register a handler, but it does not get invoked when a generator throws an error. The error param in therun()
callback isn't set either. What's going on? How do we catch errors?The text was updated successfully, but these errors were encountered: