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
Change messaging #211
Change messaging #211
Conversation
JaCoCo Code Coverage 77.75% ✅
Generated by 🚫 Danger |
I think these messages are a bit cryptic, however, I don't think including these extra parameters is that useful. It might be better to document common causes of this exception and link to it. |
@@ -101,7 +101,7 @@ internal class ScopedCallbacks private constructor( | |||
|
|||
private fun ensureNotRunning() { | |||
if (!enabled) { | |||
throw java.lang.IllegalStateException("cannot call this callback $currentKey after evaluation finished.") | |||
throw java.lang.IllegalStateException("cannot call this callback after evaluation finished. See https://instacart.github.io/formula/faq/#after-evaluation-finished") |
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.
Could we capitalize cannot
?
@@ -42,7 +42,7 @@ class FormulaContextImpl<State> internal constructor( | |||
|
|||
private fun ensureNotRunning() { | |||
if (transitionCallback.running) { | |||
throw IllegalStateException("cannot call this transition $transitionId after evaluation finished.") | |||
throw IllegalStateException("cannot call this transition after evaluation finished. See https://instacart.github.io/formula/faq/#after-evaluation-finished") |
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.
Could we capitalize cannot
?
docs/faq.md
Outdated
within the `evaluate` function itself, passing the data you might be using from the `onEvent` into | ||
the `State` defined for that Formula. For example, instead of: | ||
``` | ||
class RelatedSearchesFormula @Inject constructor( |
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.
The description is perfect, however, I think the example might be a bit too complicated and actually doesn't contain the context.callback
usage. I wonder if we could use a simple task example, such as
RxStream.fromObservable { repo.fetchTask(input.taskId) }.onEvent { task ->
val renderModel = TaskDetailRenderModel(
title = task.title,
// Don't do: calling context.callback within "onEvent" will cause a crash described above
onDeleteSelected = context.callback {
...
}
)
transition(state.copy(task = renderModel))
}
@Laimiux updated, what do you think? |
Looks great, merged the PR! |
Seeing the error message
cannot call this after evaluation finished.
is a little unactionable and hard to tell where it is coming from or what it is referring to unless you look at the source of Formula. So, this should make it a little more clear.