- Notifications
You must be signed in to change notification settings - Fork928
feat(cli): add error message for bad login URL#4042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
feat(cli): add error message for bad login URL#4042
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
cli/login.go Outdated
@@ -83,7 +83,7 @@ func login() *cobra.Command { | |||
hasInitialUser, err := client.HasFirstUser(cmd.Context()) | |||
if err != nil { | |||
return xerrors.Errorf("has initialuser: %w", err) | |||
return xerrors.Errorf("Failed to check server %q for firstuser, is the URL correct and is coder accessible from your browser? Error: %w", serverURL.String(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I wish we could print this on two lines:
"friendly message..
error output...
"
but when I add\n
it prints the error output twice. Any ideas@deansheather ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
in that case you just write log output to stderr with your message and thenreturn xerrors.Errorf("has initial user: %w", err)
afterwards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I triedfmt.Fprintln(cmd.ErrOrStderr(), errMsg)
but then my test doesn't pass. Any pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Talked offline. I'll have it match thehas initial user
message.
a9bd76c
to0782811
Compare@@ -83,7 +83,7 @@ func login() *cobra.Command { | |||
hasInitialUser, err := client.HasFirstUser(cmd.Context()) | |||
if err != nil { | |||
return xerrors.Errorf("has initial user: %w", err) | |||
return xerrors.Errorf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser? Error -has initial user: %w", serverURL.String(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thought about this a bit more last night...Since this is user-facing, I think the friendly error message should be included in the test assertion. Otherwise, it can be removed and the test would still pass. Then we'd have a working CLI with poor UX. Instead, we want to ensure we have good UX.
cc@deansheather ready for another review |
Uh oh!
There was an error while loading.Please reload this page.
This adds a more friendly error message when a user mistypes the user when running
coder login <url>
. Open to additional feedback/suggestions!Fixes#3963
To test locally, run: