Skip to content
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

Improved handling of HTTP response errors #152

Merged
merged 12 commits into from
Nov 9, 2023
Prev Previous commit
Next Next commit
Fix select warnings in console
  • Loading branch information
dotasek committed Nov 9, 2023
commit e094518835dbc0553d04d1da138ac1f8a0cd6e13
15 changes: 15 additions & 0 deletions src/commonMain/kotlin/model/ValidationResponseException.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package model


public class ValidationException internal constructor(
message: String
) : Throwable(message), CopyableThrowable<ValidationException> {
/**
* Creates a timeout exception with the given message.
* This constructor is needed for exception stack-traces recovery.
*/
@Suppress("UNUSED")
internal constructor(message: String) : this(message)

// message is never null in fact
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class LanguageSelect(props : LanguageSelectProps) : RComponent<LanguageSelectPro
+props.polyglot.t("language")
}
Select {

attrs {
label = ReactNode("Language")
value = props.selectedLanguage.getLanguageCode().unsafeCast<Nothing?>()
onChange = { event, _ ->
val selectedLanguage = Language.getSelectedLanguage(event.target.value)
if (selectedLanguage != null) {
Expand Down
11 changes: 9 additions & 2 deletions src/jsMain/kotlin/ui/components/options/PresetSelect.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ external interface PresetSelectProps : Props {

class PresetSelectState : State {
var snackbarOpen : String? = null
var preset : String = ""
}

class PresetSelect : RComponent<PresetSelectProps, PresetSelectState>() {
Expand Down Expand Up @@ -81,7 +82,8 @@ class PresetSelect : RComponent<PresetSelectProps, PresetSelectState>() {
}
Select {
attrs {
label = ReactNode("preset")
label = ReactNode("Preset")
value = "".unsafeCast<Nothing?>()
onChange = { event, _ ->
val selectedPreset = Preset.getSelectedPreset(event.target.value)
if (selectedPreset != null) {
Expand Down Expand Up @@ -121,7 +123,12 @@ class PresetSelect : RComponent<PresetSelectProps, PresetSelectState>() {
open = state.snackbarOpen != null
message = ReactNode(
props.polyglot.t("preset_notification",
getJS(arrayOf(Pair("selectedPreset", props.polyglot.t(state.snackbarOpen.toString())))))
getJS(arrayOf(Pair("selectedPreset",
if (state.snackbarOpen != null)
props.polyglot.t(state.snackbarOpen.toString())
else
"---"
))))
)
autoHideDuration=6000
onClose = { event, _ -> handleSnackBarClose() }
Expand Down