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 all 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!(
"{} 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