Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Handle failed exit codes elegantly #799

Merged
merged 4 commits into from
Oct 24, 2019

Conversation

EverlastingBugstopper
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper commented Oct 23, 2019

Instead of printing out this error:

$ wrangler generate my-rust https://github.com/EverlastingBugstopper/rustwasm-worker-template/🌀  🐑  Generating a new rust worker project with name 'my-rust'...
🔧   Creating project called `my-rust`...
Error: ⛔   Target directory already exists, aborting!
Error: failed to execute `"/Users/averyharnish/.cargo/bin/cargo-generate" "generate" "--git" "https://github.com/EverlastingBugstopper/rustwasm-worker-template/" "--name" "my-rust" "--force"`: exited with exit code: 1

print out this error that lets people copy and paste the command we tried to run easier (before it had a bunch of quotes in it):

$ wrangler generate my-rust https://github.com/EverlastingBugstopper/rustwasm-worker-template/
🌀  🐑  Generating a new worker project with name 'my-rust'...
🔧   Creating project called `my-rust`...
Error: ⛔   Target directory already exists, aborting!
Error: command exited with exit code: 1
`/Users/averyharnish/.cargo/bin/cargo-generate generate --git https://github.com/EverlastingBugstopper/rustwasm-worker-template/ --name my-rust --force`

@EverlastingBugstopper EverlastingBugstopper changed the base branch from master to avery/toml-more-like-big-gulp October 23, 2019 18:09
src/commands/mod.rs Outdated Show resolved Hide resolved
src/commands/mod.rs Outdated Show resolved Hide resolved
@EverlastingBugstopper
Copy link
Contributor Author

reason i'm looking at this is because of cargo-generate/cargo-generate#198

@exvuma
Copy link
Contributor

exvuma commented Oct 23, 2019

While we are at it, could we remove these redundant lines?

🌀  🐑  Generating a new worker project with name 'my-rust'...
🔧   Creating project called `my-rust`...

seems those lines are saying the same thing?

@EverlastingBugstopper
Copy link
Contributor Author

Totally!

@ashleygwilliams ashleygwilliams added this to the 1.5.0 milestone Oct 24, 2019
@ashleygwilliams ashleygwilliams merged commit 3f8ae7a into avery/toml-more-like-big-gulp Oct 24, 2019
@ashleygwilliams ashleygwilliams deleted the avery/exit-codes branch October 24, 2019 14:52
"failed to execute `{}`: exited with {}",
command_name,
status
"command exited with {}\n`{}`",
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as other PR... I liked the ordering of printouts in the old message more, actually! Feel free to keep the replace logic though.

@ashleygwilliams ashleygwilliams added feature Feature requests and suggestions changelog - feature and removed feature Feature requests and suggestions labels Oct 25, 2019
status
"command exited with {}\n`{}`",
status,
command_name.replace("\"", "")
Copy link
Member

@xtuc xtuc Oct 25, 2019

Choose a reason for hiding this comment

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

Why does the command_name have quotes? Do we need to add them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirely sure why it has quotes, I think it has something to do with the implementation of Display on Command (although I'm not sure). After this the quotes are removed though - I don't think we are the ones that implemented the quotes in the first place.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants