-
Notifications
You must be signed in to change notification settings - Fork 15
setup script can communicate an error message to the end user #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+107
−14
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88134ba
setup script can communicate an error message to the end user
kirillk 55870c4
review fixes
kirillk eb5e2ac
custom exception class for setup command
kirillk c0b6fea
better title
kirillk e3a37fb
Merge branch 'main' into kkalishev/setup-script-error
bcpeinhardt acc6a7f
changelog update
bcpeinhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/com/coder/gateway/CoderSetupCommandException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.coder.gateway | ||
|
||
class CoderSetupCommandException : Exception { | ||
|
||
constructor(message: String) : super(message) | ||
constructor(message: String, cause: Throwable) : super(message, cause) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/test/kotlin/com/coder/gateway/util/SetupCommandTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.coder.gateway.util | ||
|
||
import com.coder.gateway.CoderRemoteConnectionHandle.Companion.processSetupCommand | ||
import com.coder.gateway.CoderSetupCommandException | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertThrows | ||
import kotlin.test.assertEquals | ||
|
||
internal class SetupCommandTest { | ||
|
||
@Test | ||
fun executionErrors() { | ||
assertEquals( | ||
"Execution error", | ||
assertThrows<CoderSetupCommandException> { | ||
processSetupCommand(false) { throw Exception("Execution error") } | ||
}.message | ||
) | ||
processSetupCommand(true) { throw Exception("Execution error") } | ||
} | ||
|
||
@Test | ||
fun setupScriptError() { | ||
assertEquals( | ||
"Your IDE is expired, please update", | ||
assertThrows<CoderSetupCommandException> { | ||
processSetupCommand(false) { | ||
""" | ||
execution line 1 | ||
execution line 2 | ||
CODER_SETUP_ERRORYour IDE is expired, please update | ||
execution line 3 | ||
""" | ||
} | ||
}.message | ||
) | ||
|
||
processSetupCommand(true) { | ||
""" | ||
execution line 1 | ||
execution line 2 | ||
CODER_SETUP_ERRORYour IDE is expired, please update | ||
execution line 3 | ||
""" | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.