Skip to content

Commit 9f0239f

Browse files
authored
Improve error logging for sign-in dialog (#3550)
1 parent d2cb35e commit 9f0239f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/core/credentials/ToolkitAddConnectionDialog.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import software.aws.toolkits.jetbrains.core.credentials.sono.SONO_URL
3838
import software.aws.toolkits.jetbrains.core.help.HelpIds
3939
import software.aws.toolkits.resources.message
4040
import software.aws.toolkits.telemetry.UiTelemetry
41+
import java.io.IOException
4142
import javax.swing.JComponent
4243

4344
data class ConnectionDialogCustomizer(
@@ -117,7 +118,7 @@ open class ToolkitAddConnectionDialog(
117118
try {
118119
// Edge case when user choose SSO but enter AWS Builder ID url
119120
if (loginType == LoginOptions.SSO && startUrl == SONO_URL) {
120-
error("User should not do SSO login with AWS Builder ID url")
121+
error("User should not perform Identity Center login with AWS Builder ID url")
121122
}
122123

123124
val scopes = if (loginType == LoginOptions.AWS_BUILDER_ID) {
@@ -133,11 +134,19 @@ open class ToolkitAddConnectionDialog(
133134
}
134135
} catch (e: Exception) {
135136
val message = when (e) {
137+
is IllegalStateException -> e.message ?: message("general.unknown_error")
136138
is ProcessCanceledException -> message("codewhisperer.credential.login.dialog.exception.cancel_login")
137139
is InvalidGrantException -> message("codewhisperer.credential.login.exception.invalid_grant")
138140
is InvalidRequestException -> message("codewhisperer.credential.login.exception.invalid_input")
139141
is SsoOidcException -> message("codewhisperer.credential.login.exception.general.oidc")
140-
else -> message("codewhisperer.credential.login.exception.general")
142+
else -> {
143+
val baseMessage = when (e) {
144+
is IOException -> "codewhisperer.credential.login.exception.io"
145+
else -> "codewhisperer.credential.login.exception.general"
146+
}
147+
148+
message(baseMessage, "${e.javaClass.name}: ${e.message}")
149+
}
141150
}
142151
LOG.warn(e) { message }
143152
setErrorText(message)

resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,11 @@ codewhisperer.credential.login.dialog.iam.description=Not supported by CodeWhisp
436436
codewhisperer.credential.login.dialog.ok_button=Connect
437437
codewhisperer.credential.login.dialog.prompt=Select a connection option to start using CodeWhisperer
438438
codewhisperer.credential.login.dialog.title=CodeWhisperer: Add Connection to AWS
439-
codewhisperer.credential.login.exception.general=Run into unknown error
439+
codewhisperer.credential.login.exception.general=Ran into unknown error: {0}
440440
codewhisperer.credential.login.exception.general.oidc=Fail to fetch credential
441441
codewhisperer.credential.login.exception.invalid_grant=Access denied
442442
codewhisperer.credential.login.exception.invalid_input=Invalid start url
443+
codewhisperer.credential.login.exception.io=Unable to access SSO disk cache: {0}
443444
codewhisperer.credential.login.prompt.sono.message=Sign in with AWS Builder ID
444445
codewhisperer.credential.login.prompt.sono.title=AWS Builder ID login
445446
codewhisperer.experiment=CodeWhisperer

0 commit comments

Comments
 (0)