Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Most fallible methods should return Result<T, failure::Error> instead of Result<T, wasm_pack::error::Error> #280

Closed
fitzgen opened this issue Sep 5, 2018 · 9 comments · Fixed by #401
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed refactor

Comments

@fitzgen
Copy link
Member

fitzgen commented Sep 5, 2018

A wasm_pack::error::Error will Into a failure::Error so existing ? locations shouldn't need any changes.

Basically, only "leaf" errors should be wasm_pack::error::Error and everything else should be failure::Error.

Then we should put .context("..") (or .with_context(|e| ...)) onto all non-leaf ? sites, providing better error messages and cause-and-effect chains.

@fitzgen fitzgen added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers refactor labels Sep 5, 2018
@stuarth
Copy link

stuarth commented Sep 11, 2018

I'd be happy to take this one!

@stuarth
Copy link

stuarth commented Sep 11, 2018

@fitzgen wanted to check my understanding on this. The idea is I'll convert a fn like

step_check_crate_config to Result<(), failure::Error> and add a context / with_context to its call to check_crate_config

What I'm not seeing -- and apologies if I'm overlooking something obvious -- is the best way to convert that failure:Error to a wasm_pack::error::Error in a fn like run

Thanks!

@fitzgen
Copy link
Member Author

fitzgen commented Sep 11, 2018

step_check_crate_config to Result<(), failure::Error> and add a context / with_context to its call to check_crate_config

Correct.

What I'm not seeing -- and apologies if I'm overlooking something obvious -- is the best way to convert that failure:Error to a wasm_pack::error::Error in a fn like run

All those should become failure::Errors too, so no need to convert to wasm_pack::error::Error ;)

Thanks!

Thank you!

@stuarth
Copy link

stuarth commented Sep 11, 2018

Ah, gotcha. I think I'd misread your intent with leaf / non-leaf.

Am I right in thinking that when you say "leaf" you mean something like a function that reads a config from disk? And a non-leaf fn is one that builds on top of it, e.g. initiating a build that depends on that config?

@stuarth
Copy link

stuarth commented Sep 27, 2018

Sorry about the inactivity -- life has crept up in a major way and I haven't had a chance to get to this yet. If anyone wants to take a stab at it, please do!

@drager
Copy link
Member

drager commented Oct 4, 2018

I would like to give this a shot. I will try to start working on this soon and create a PR when I have. In the meantime if someone else would like to grab this, please do and let me know if that's the case. :)

@fitzgen
Copy link
Member Author

fitzgen commented Oct 4, 2018

I ended up doing part of this work in #392 (3rd commit) if you want some examples of what needs to happen here.

I only did enough to give better context to errors when running child processes, so there should be a bunch of places that are still not using failure::Error and a bunch of places taht need .context("...").

@fitzgen
Copy link
Member Author

fitzgen commented Oct 4, 2018

Oh! And it might make sense to branch off of my PR to avoid a bunch of merge conflict ickiness -- sorry!

@drager
Copy link
Member

drager commented Oct 7, 2018

@fitzgen: Thank you for the information, I will branch out from your PR.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed refactor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants