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

Task error handling #3245

Open
fortmarek opened this issue Jul 29, 2021 · 2 comments
Open

Task error handling #3245

fortmarek opened this issue Jul 29, 2021 · 2 comments
Labels
good first issue Good for newcomers

Comments

@fortmarek
Copy link
Member

Describe the bug

The task closure is marked as throwing, but errors thrown from here are not handled. I initially created a custom error and threw it as a form of validation (e.g. an invalid path provided)

To Reproduce

Create a task, throw an error inside and then run it

Expected behavior
We should handle this gracefully

@wattson12
Copy link
Contributor

@fortmarek thanks for creating these issues, I've taken a very quick look at handling error throwing but have some concerns about my implementation. You can see the code here but the things I wasn't sure about:

  • This uses print to output the error because ProjectAutomation doesn't import TuistSupport so I couldn't use a logger instance
  • Should error handling happen within Task.swift or should it be exiting with a message which is captured by an error handler within the ExecCommand code?

Happy to have a chat about this change, either here or I'm in the tuist slack as well

@fortmarek
Copy link
Member Author

This uses print to output the error because ProjectAutomation doesn't import TuistSupport so I couldn't use a logger instance

Indeed, you can't!

Should error handling happen within Task.swift or should it be exiting with a message which is captured by an error handler within the ExecCommand code?

This way we can reuse the logger functionality, so I think this is a good step forward 👍

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

No branches or pull requests

4 participants