@@ -49,19 +49,35 @@ open class CoderProtocolHandler(
49
49
val queryToken = params.token()
50
50
val restClient = try {
51
51
authenticate(deploymentURL, queryToken)
52
- } catch (ex: MissingArgumentException ) {
53
- throw MissingArgumentException (" Query parameter \" $TOKEN \" is missing" , ex)
52
+ } catch (ex: Exception ) {
53
+ context.logger.error(ex, " Query parameter \" $TOKEN \" is missing from URI $uri " )
54
+ context.ui.showErrorInfoPopup(
55
+ IllegalStateException (
56
+ humanizeConnectionError(
57
+ deploymentURL.toURL(),
58
+ true ,
59
+ ex
60
+ )
61
+ )
62
+ )
63
+ return
54
64
}
55
65
56
- // TODO: Show a dropdown and ask for the workspace if missing.
57
- val workspaceName =
58
- params.workspace() ? : throw MissingArgumentException (" Query parameter \" $WORKSPACE \" is missing" )
66
+ // TODO: Show a dropdown and ask for the workspace if missing. Right now it's not possible because dialogs are quite limited
67
+ val workspaceName = params.workspace()
68
+ if (workspaceName.isNullOrBlank()) {
69
+ context.logger.error(" Query parameter \" $WORKSPACE \" is missing from URI $uri " )
70
+ context.ui.showErrorInfoPopup(MissingArgumentException (" Can't handle URI because query parameter \" $WORKSPACE \" is missing" ))
71
+ return
72
+ }
59
73
60
74
val workspaces = restClient.workspaces()
61
- val workspace =
62
- workspaces.firstOrNull {
63
- it.name == workspaceName
64
- } ? : throw IllegalArgumentException (" The workspace $workspaceName does not exist" )
75
+ val workspace = workspaces.firstOrNull { it.name == workspaceName }
76
+ if (workspace == null ) {
77
+ context.logger.error(" There is no workspace with name $workspaceName on $deploymentURL " )
78
+ context.ui.showErrorInfoPopup(MissingArgumentException (" Can't handle URI because workspace with name $workspaceName does not exist" ))
79
+ return
80
+ }
65
81
66
82
when (workspace.latestBuild.status) {
67
83
WorkspaceStatus .PENDING , WorkspaceStatus .STARTING ->
@@ -188,13 +204,8 @@ open class CoderProtocolHandler(
188
204
PluginManager .pluginInfo.version,
189
205
httpClient
190
206
)
191
- return try {
192
- client.authenticate()
193
- client
194
- } catch (ex: Exception ) {
195
- context.ui.showErrorInfoPopup(IllegalStateException (humanizeConnectionError(client.url, true , ex)))
196
- throw ex
197
- }
207
+ client.authenticate()
208
+ return client
198
209
}
199
210
200
211
/* *
0 commit comments