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

Commit

Permalink
Merge pull request #813 from pradovic/fix/duplicate-error-routes
Browse files Browse the repository at this point in the history
Handle duplicate route error gracefully
  • Loading branch information
ashleygwilliams committed Oct 29, 2019
2 parents 9925cde + eb5a527 commit d3ed0ec
Showing 1 changed file with 15 additions and 5 deletions.
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!(
"{} 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",
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

0 comments on commit d3ed0ec

Please sign in to comment.