Skip to content

Commit

Permalink
surface error message to users if plugin can't read aws/config file (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-ShaoHua committed Jun 11, 2024
1 parent 8e11060 commit 4e5b072
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package software.aws.toolkits.jetbrains.core.credentials
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFileManager
import org.slf4j.LoggerFactory
import org.slf4j.event.Level
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.profiles.Profile
Expand All @@ -30,6 +32,8 @@ import software.aws.toolkits.telemetry.CredentialSourceId
import software.aws.toolkits.telemetry.Result
import java.io.IOException

private val LOG = LoggerFactory.getLogger("LoginUtils")

sealed interface Login {
val id: CredentialSourceId

Expand Down Expand Up @@ -58,12 +62,9 @@ sealed interface Login {

fun loginIdc(project: Project): AwsBearerTokenConnection? {
// we have this check here so we blow up early if user has an invalid config file
try {
LOG.tryOrNull("Failed to read sso sessions file", level = Level.ERROR) {
configFilesFacade.readSsoSessions()
} catch (e: Exception) {
println("Failed to read sso sessions file")
return null
}
} ?: return null

val profile = UserConfigSsoSessionProfile(
configSessionName = validatedSsoIdentifierFromUrl(startUrl),
Expand Down

0 comments on commit 4e5b072

Please sign in to comment.