Skip to content

feat(error_msg): Make custom module for errors #120

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

Merged
merged 1 commit into from
May 2, 2018
Merged

feat(error_msg): Make custom module for errors #120

merged 1 commit into from
May 2, 2018

Conversation

mgattozzi
Copy link
Contributor

This does two big things:

  • We add custom error messages and conversions from other error types
    into our own error type. This means we can create or modify more
    fine grained errors rather than using whatever failure::Error gives
    us. The first one we have is a Cli error, whereby calls to things
    like wasm-bindgen or npm failed.
  • We also make it so that PBAR.error() is called only on exit. We grab
    a reference to whatever error gets passed up the chain, have it
    generate a message to be printed as an error to PBAR, close up PBAR
    like normal, and then print our actual error message to stderr!

The main benefits of this is that as long as we return an error, PBAR
will print and close itself up and we don't need to call it every time
or forget that we would need to call it, and we put error details
specifically into our error!

Closes #12

Make sure these boxes are checked! 📦✅

  • You have the latest version of rustfmt installed and have your
    cloned directory set to nightly
$ rustup override set nightly
$ rustup component add rustfmt-preview --toolchain nightly
  • You ran rustfmt on the code base before submitting
  • You reference which issue is being closed in the PR text

✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨

This does two big things:

- We add custom error messages and conversions from other error types
  into our own error type. This means we can create or modify more
  fine grained errors rather than using whatever `failure::Error` gives
  us. The first one we have is a `Cli` error, whereby calls to things
  like wasm-bindgen or npm failed.
- We also make it so that `PBAR.error()` is called only on exit. We grab
  a reference to whatever error gets passed up the chain, have it
  generate a message to be printed as an error to PBAR, close up PBAR
  like normal, and then print our actual error message to stderr!

The main benefits of this is that as long as we return an error, PBAR
will print and close itself up and we don't need to call it every time
or forget that we would need to call it, and we put error details
specifically into our error!

Closes #12
@mgattozzi mgattozzi requested a review from ashleygwilliams May 1, 2018 21:00
@mgattozzi
Copy link
Contributor Author

Example output:

2018-05-01-170147_1965x667_scrot

Copy link
Member

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like it and think this looks great. thank you SO MUCH!!

@ashleygwilliams ashleygwilliams merged commit 4e98b42 into rustwasm:master May 2, 2018
@mgattozzi mgattozzi deleted the error-error-on-the-wall-whats-the-deal-with-them-all branch May 2, 2018 20:11
@mgattozzi
Copy link
Contributor Author

Awesome! Glad you liked that refactor of error handling a bit! :D Another issue down!

@mgattozzi mgattozzi added this to the 0.3.0 milestone May 29, 2018
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

Successfully merging this pull request may close these issues.

handle the specific errors specifically
2 participants