What would be the recommended approach to error ha...
# compose
a
What would be the recommended approach to error handling text input in a composable show below? I could define an interface for the textfields that handle number input, and implement it based on whether it needs input validation but I am unsure if that is a good approach. Code in 🧵. ``````
Copy code
@Composable
fun EditExerciseContent(exercise: Exercise, onExerciseChanged: (Exercise) -> Unit) {
    Column(Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
        Column(Modifier.fillMaxWidth(0.9f)) {
            SimpleOutlinedTextFieldSample(
                exercise.exerciseName,
                "Exercise Name",
                isError = false,
                keyboardType = KeyboardType.Text,
                onTextChanged = {
                    val newExercise = exercise.copy(exerciseName = it)
                    onExerciseChanged(newExercise)
                }, modifier = Modifier.fillMaxWidth()
            )
            Spacer(Modifier.height(16.dp))
            SimpleOutlinedTextFieldSample(
                if (exercise.exerciseWeight == null) "" else exercise.exerciseWeight.toString(),
                "Exercise Weight",
                isError = false,
                keyboardType = KeyboardType.Number,
                onTextChanged = {
                    val newExercise = exercise.copy(exerciseWeight = it.toInt())
                    onExerciseChanged(newExercise)
                }, modifier = Modifier.fillMaxWidth()
            )
            Spacer(Modifier.height(16.dp))
            SimpleOutlinedTextFieldSample(
                if (exercise.exerciseSets == null) "" else exercise.exerciseSets.toString(),
                "Set Count",
                isError = false,
                keyboardType = KeyboardType.Number,
                onTextChanged = {
                    val newExercise = exercise.copy(exerciseSets = it.toInt())
                    onExerciseChanged(newExercise)
                }, modifier = Modifier.fillMaxWidth()
            )
            Spacer(Modifier.height(16.dp))
            SimpleOutlinedTextFieldSample(
                if (exercise.exerciseSets == null) "" else exercise.exerciseReps.toString(),
                "Rep Count",
                isError = false,
                keyboardType = KeyboardType.Number,
                onTextChanged = {
                    val newExercise = exercise.copy(exerciseReps = it.toInt())
                    onExerciseChanged(newExercise)
                }, modifier = Modifier.fillMaxWidth()
            )
        }
    }
}
t
what is the error handling portion that you mentioned here?