Skip to content

Commit 37c7d31

Browse files
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 PR
1 parent aed711f commit 37c7d31

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

internal/authutil/credentials.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ActiveUserKey = "active_user"
2323
const KnownUsersKey = "known_users"
2424

2525
// ErrNoActiveUser indicates that no active user is set in the keyring.
26-
var ErrNoActiveUser = errors.New("no active user set. Please login first")
26+
var ErrNoActiveUser = errors.New("no active user set. Please login first using 'datumctl auth login'")
2727

2828
// StoredCredentials holds all necessary information for a single authenticated session.
2929
type StoredCredentials struct {

0 commit comments

Comments
 (0)