Skip to content

Commit 088640b

Browse files
committed
Show simple warning message from the message queue.
1 parent 9602113 commit 088640b

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

cmd/state/internal/cmdtree/exechandlers/messages/messenger.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,7 @@ func (m *Messenger) OnExecStart(_ *captain.Command, _ []string) error {
6262
}
6363

6464
func (m *Messenger) handleErrorMessages(message *graph.Message) {
65-
switch message.Topic {
66-
case msgs.TopicErrorAuth:
67-
logging.Error("State Service reported an authentication error: %s", message.Message)
68-
err := locale.NewError("err_svc_message", "The State Service reported an authentication error: {{.V0}}", message.Message)
69-
m.out.Error(err)
70-
case msgs.TopicErrorAuthToken:
71-
logging.Error("State Service reported an authentication token error: %s", message.Message)
72-
err := locale.NewError("err_svc_invalid_token", "", message.Message)
73-
m.out.Error(err)
74-
default:
75-
logging.Error("State Service reported an unknown error: %s", message.Topic)
76-
m.out.Error(locale.NewError("err_svc_unknown_message", "The State Service reported an unknown error: {{.V0}}", message.Message))
77-
}
65+
logging.Error("State Service reported a %s error: %s", message.Topic, message.Message)
66+
err := locale.NewError("err_svc_message", "[WARNING]Warning:[/RESET] {{.V0}}", message.Message)
67+
m.out.Error(err)
7868
}

internal/locale/locales/en-us.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ err_read_projectfile:
933933
err_auth_fail_totp:
934934
other: A two-factor authentication code is required.
935935
err_invalid_token:
936-
other: Invalid API token
936+
other: Invalid API token. Please check your API token and try again.
937937
err_invalid_credentials:
938938
other: Invalid credentials
939939
cve_title:
@@ -1593,7 +1593,3 @@ config_set_help:
15931593
other: "To SET the value for a specific config key run '[ACTIONABLE]state config set <key> <value>[/RESET]'"
15941594
err_clean_in_use:
15951595
other: "Could not clean your cache as you appear to have a runtime in use. Please stop any running State Tool processes and project runtime processes and try again."
1596-
err_svc_invalid_token:
1597-
other: |
1598-
The State Service reported an invalid API token error: {{.V0}}
1599-
Please check your API token and try again.

test/integration/auth_int_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ func (suite *AuthIntegrationTestSuite) TestAuth_InvalidToken() {
120120

121121
cp := ts.SpawnWithOpts(e2e.OptArgs("--version"), e2e.OptAppendEnv(constants.APIKeyEnvVarName+"=bad-token"))
122122
// Message is displayed
123-
cp.Expect("The State Service reported an invalid API token error: Invalid API token")
124-
cp.Expect("Please check your API token and try again.")
123+
cp.Expect("Warning: Invalid API token")
125124
// The version information is still displayed
126125
cp.Expect("ActiveState CLI")
127126
cp.Expect("Version")

0 commit comments

Comments
 (0)