@@ -18,6 +18,7 @@ import com.coder.gateway.sdk.TemplateIconDownloader
1818import com.coder.gateway.sdk.ex.AuthenticationResponseException
1919import com.coder.gateway.sdk.ex.TemplateResponseException
2020import com.coder.gateway.sdk.ex.WorkspaceResponseException
21+ import com.coder.gateway.sdk.isCancellation
2122import com.coder.gateway.sdk.toURL
2223import com.coder.gateway.sdk.v2.models.WorkspaceStatus
2324import com.coder.gateway.sdk.v2.models.toAgentModels
@@ -424,11 +425,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
424425
425426 // Authenticate and load in a background process with progress.
426427 // TODO: Make this cancelable.
427- return LifetimeDefinition ().launchUnderBackgroundProgress(
428- CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.cli.downloader.dialog.title" ),
429- canBeCancelled = false ,
430- isIndeterminate = true
431- ) {
428+ return LifetimeDefinition ().launchUnderBackgroundProgress(CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.cli.downloader.dialog.title" )) {
432429 try {
433430 this .indicator.text = " Authenticating client..."
434431 authenticate(deploymentURL, token.first)
@@ -456,51 +453,55 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
456453 tableOfWorkspaces.setEmptyState(CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.connect.text.connected" , deploymentURL.host))
457454 tfUrlComment?.text = CoderGatewayBundle .message(" gateway.connector.view.coder.workspaces.connect.text.connected" , deploymentURL.host)
458455 } catch (e: Exception ) {
459- val reason = e.message ? : CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.no-reason" )
460- val msg = when (e) {
461- is java.nio.file.AccessDeniedException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.access-denied" , e.file)
462- is UnknownHostException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unknown-host" , e.message ? : deploymentURL.host)
463- is InvalidExitValueException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unexpected-exit" , e.exitValue)
464- is AuthenticationResponseException -> {
465- CoderGatewayBundle .message(
466- " gateway.connector.view.workspaces.connect.unauthorized" ,
467- deploymentURL,
468- )
469- }
470- is SocketTimeoutException -> {
471- CoderGatewayBundle .message(
472- " gateway.connector.view.workspaces.connect.timeout" ,
473- deploymentURL,
474- )
475- }
476- is ResponseException , is ConnectException -> {
477- CoderGatewayBundle .message(
478- " gateway.connector.view.workspaces.connect.download-failed" ,
479- reason,
480- )
456+ if (isCancellation(e)) {
457+ CoderRemoteConnectionHandle .logger.info(" Connection canceled due to ${e.javaClass.simpleName} " )
458+ } else {
459+ val reason = e.message ? : CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.no-reason" )
460+ val msg = when (e) {
461+ is java.nio.file.AccessDeniedException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.access-denied" , e.file)
462+ is UnknownHostException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unknown-host" , e.message ? : deploymentURL.host)
463+ is InvalidExitValueException -> CoderGatewayBundle .message(" gateway.connector.view.workspaces.connect.unexpected-exit" , e.exitValue)
464+ is AuthenticationResponseException -> {
465+ CoderGatewayBundle .message(
466+ " gateway.connector.view.workspaces.connect.unauthorized" ,
467+ deploymentURL,
468+ )
469+ }
470+ is SocketTimeoutException -> {
471+ CoderGatewayBundle .message(
472+ " gateway.connector.view.workspaces.connect.timeout" ,
473+ deploymentURL,
474+ )
475+ }
476+ is ResponseException , is ConnectException -> {
477+ CoderGatewayBundle .message(
478+ " gateway.connector.view.workspaces.connect.download-failed" ,
479+ reason,
480+ )
481+ }
482+ is SSLHandshakeException -> {
483+ CoderGatewayBundle .message(
484+ " gateway.connector.view.workspaces.connect.ssl-error" ,
485+ deploymentURL.host,
486+ reason,
487+ )
488+ }
489+ else -> reason
481490 }
482- is SSLHandshakeException -> {
483- CoderGatewayBundle .message(
484- " gateway.connector.view.workspaces.connect.ssl-error" ,
485- deploymentURL.host,
486- reason,
487- )
491+ // It would be nice to place messages directly into the table
492+ // but it does not support wrapping or markup so place it in the
493+ // comment field of the URL input instead.
494+ tfUrlComment?.foreground = UIUtil .getErrorForeground()
495+ tfUrlComment?.text = msg
496+ tableOfWorkspaces.setEmptyState(CoderGatewayBundle .message(
497+ " gateway.connector.view.workspaces.connect.failed" ,
498+ deploymentURL.host,
499+ ))
500+ logger.error(msg, e)
501+
502+ if (e is AuthenticationResponseException ) {
503+ cs.launch { onAuthFailure?.invoke() }
488504 }
489- else -> reason
490- }
491- // It would be nice to place messages directly into the table
492- // but it does not support wrapping or markup so place it in the
493- // comment field of the URL input instead.
494- tfUrlComment?.foreground = UIUtil .getErrorForeground()
495- tfUrlComment?.text = msg
496- tableOfWorkspaces.setEmptyState(CoderGatewayBundle .message(
497- " gateway.connector.view.workspaces.connect.failed" ,
498- deploymentURL.host,
499- ))
500- logger.error(msg, e)
501-
502- if (e is AuthenticationResponseException ) {
503- cs.launch { onAuthFailure?.invoke() }
504505 }
505506 }
506507 }
0 commit comments