Skip to content

Conversation

kirillk
Copy link
Contributor

@kirillk kirillk commented Feb 18, 2025

Setup script can provide an error message to be shown to the end user.

Example:
Screen Shot 2025-02-18 at 3 48 55 PM

?.let { it.substring(it.indexOf(GATEWAY_SETUP_COMMAND_ERROR) + GATEWAY_SETUP_COMMAND_ERROR.length).trim() }

if (!errorText.isNullOrBlank()) {
throw Exception(errorText)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in Java&Kotlin it is best to avoid throwing the generic exception, for many reasons - but some of them are that it's too generic, and probably the most important one: upstream code can be forced to catch all checked exceptions

In other words we should be more specific and throw one of java/kotlin checked exceptions or we can create our own custom exception. IOException is probably good enough, or maybe something custom like CmdExecutionException.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, just tried not to change the code much. So do we want a new exception type for this? What do you want it to be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I called it CoderSetupCommandException and provided handling when we show the dialog so it's clearly says what it's a setup command problem, not just an abstract exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@kirillk kirillk requested a review from fioan89 February 19, 2025 17:07
Copy link
Collaborator

@fioan89 fioan89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but please wait for Benjamin's approval as well

class CoderSetupCommandException : Exception {

constructor(message: String) : super(message)
constructor(message: String, cause: Throwable) : super(message, cause)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a more simpler approach:

class CoderSetupCommandException(message: String, cause: Throwable? = null) : Exception(message, cause)

@@ -523,5 +534,26 @@ class CoderRemoteConnectionHandle {

companion object {
val logger = Logger.getInstance(CoderRemoteConnectionHandle::class.java.simpleName)
@Throws(CoderSetupCommandException::class)
fun processSetupCommand(
ignoreSetupFailure: Boolean,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a comment on this PR just a note to self about how we're doing this in general: don't love us drilling down this Boolean flag for ignoring errors.

@bcpeinhardt
Copy link
Collaborator

@kirillk in response to your slack comment

Are there any principal objections to the approach we're taking in this PR?

No :)

@bcpeinhardt bcpeinhardt merged commit 3a9116f into coder:main Feb 20, 2025
5 checks passed
@Jphalan
Copy link

Jphalan commented Feb 24, 2025

@bcpeinhardt can you estimate this :) ?

@mattvollmer mattvollmer added community Pull Requests and issues created by the community. and removed community Pull Requests and issues created by the community. labels Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants