Conversation
mythmon
reviewed
May 22, 2024
src/deploy.ts
Outdated
| wrapAnsi(`Could not create project: ${error instanceof Error ? error.message : error}`, effects.outputColumns) | ||
| wrapAnsi( | ||
| `Could not create project: ${ | ||
| (error as any)?.statusCode === 409 ? "conflicting slug." : error instanceof Error ? error.message : error |
Contributor
There was a problem hiding this comment.
The type safe version of this would be something like
if (isErrorMessage(error) && error.statusCode === 409 ...This is probably fine as is.
Contributor
|
It would be nice to prompt the user in a loop instead of throwing an error, but that's a bit bigger change than I think you want to tackle in this PR. Or maybe even clack can do async validation and we can do it that way? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This error is raised when you have opted in to create a new project, but asked for an existing slug.
There are two slightly different recommendations in the two issues that discuss this problem:
This PR is a simple cosmetic display of the error; (note: I think it's fair in this case to terminate the session, since in this case we opted-in to create a new project, and not to push into an existing project—which is a way to reuse a slug; unless, there is a case where the slug is "taken" by a project you can't see?)
This does not change the workflow, but only fixes the displayed message to make it more palatable. I reckon that my code is ugly ("error as any", yuck), and maybe what we want is a clean "api error with messages" instead, like we have just above these lines. In that case there is a bit of work to do on the platform before we would fix this in the client?
I'm putting up this "ugly" solution as a PR, but feel free to reject it in favor of a nicer approach. The workflow with this PR is:
closes #909
closes #713