-
Notifications
You must be signed in to change notification settings - Fork 14
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
Handle duplicate child key errors more gracefully. #317
Conversation
@@ -18,4 +18,12 @@ object FormulaPlugins { | |||
else -> ListInspector(listOf(global, local)) | |||
} | |||
} | |||
|
|||
fun onDuplicateChildKey( |
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.
Do we want to generalize this to support other formula errors in the future? So something like:
onError(error: FormulaError)
where FormulaError
is a sealed interface
sealed interface FormulaError {
data class DuplicateKeyError(
val parentFormulaType: KClass<*>,
val childFormulaType: KClass<*>,
val key: Any,
) : FormulaError
}
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.
Maybe in the future, but for now doesn't seem necessary
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.
Any downsides of making it more generic from the start? Would avoid having to make API changes in the future
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.
Given it's pretty easy to migrate to a different design, I prefer waiting for more than one use case before designing a generic thing.
1a3b7af
to
a4ca1e9
Compare
JaCoCo Code Coverage 79.54% ✅
Generated by 🚫 Danger |
What
Instead of crashing on duplicate child key, we now add an index and notify the global listener to fix the problem. This is better behavior in production than potentially breaking the whole screen.