Commit 37c7d31
committed
fix: friendlier error for unauthenticated user
When a user is not logged, and never logged in the error message is not
that actionable. It says the user thy should login but now how to do it.
As reported by @ecv we can do a lot better.
There is another error that looks similar but exposes the right command
to run to login. This commit uses the same approach.
This is the current one in main
```
panic: failed to get token source: no active user set. Please login first
goroutine 1 [running]:
go.datum.net/datumctl/internal/cmd.RootCmd()
/home/gianarb/git/datum/datumctl/internal/cmd/root.go:38 +0xc3a
main.main()
/home/gianarb/git/datum/datumctl/main.go:15 +0x32
exit status 2
```
Here what user will get with this commit:
```
panic: failed to get token source: no active user set. Please login first using 'datumctl auth login'
goroutine 1 [running]:
go.datum.net/datumctl/internal/cmd.RootCmd()
/home/gianarb/git/datum/datumctl/internal/cmd/root.go:38 +0xc3a
main.main()
/home/gianarb/git/datum/datumctl/main.go:15 +0x32
exit status 2
```
NOTE: There is another race condition related to when we run
authentication and it prevents the `help` command to get printed to the
user. But I am working at it in another PR1 parent aed711f commit 37c7d31
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
0 commit comments