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

Handle duplicate route error gracefully #813

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/commands/publish/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,22 @@ fn create(user: &GlobalUser, target: &Target, route: &Route) -> Result<(), failu
.send()?;

if !res.status().is_success() {
let msg = format!(
"{} There was an error creating your route.\n Status Code: {}\n Msg: {}",
let msg;
if res.status().as_u16() == 10020 {
msg = format!(
"{} There was an error creating your route. Worker with a different name was found on {} route.\n",
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper Oct 28, 2019

Choose a reason for hiding this comment

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

Hey @pradovic - thanks so much for this thoughtful PR. I have a minor suggestion for the wording of the error message to make it a bit more actionable. Let me know what you think!

Suggested change
"{} There was an error creating your route. Worker with a different name was found on {} route.\n",
"{} A worker with a different name was previously deployed to `{}`. If you would like to overwrite that worker, you will need to change `name` in your `wrangler.toml` to match the currently deployed worker, or navigate to https://dash.cloudflare.com/workers and rename or delete that worker.\n",

Copy link
Contributor Author

@pradovic pradovic Oct 28, 2019

Choose a reason for hiding this comment

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

Hey @EverlastingBugstopper, thanks for the feedback, I was wondering how to phrase it better! Sounds good to me! I have updated the PR with suggested change.

emoji::WARN,
res.status(),
res.text()?
);
serde_json::to_string(&route)?
);
} else {
msg = format!(
"{} There was an error creating your route.\n Status Code: {}\n Msg: {}",
emoji::WARN,
res.status(),
res.text()?
);
}

failure::bail!(msg)
}
Ok(())
Expand Down