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

Error handling during evaluation. #230

Closed
Laimiux opened this issue Sep 10, 2021 · 2 comments
Closed

Error handling during evaluation. #230

Laimiux opened this issue Sep 10, 2021 · 2 comments

Comments

@Laimiux
Copy link
Collaborator

Laimiux commented Sep 10, 2021

What

Creating a ticket to explore improvements to error handling within Formula. Currently, an error during evaluation can crash the whole feature which isn't great in production. While such issues aren't very common, I think we should provide APIs to contain the surface area of a crash.

The most common scenario is a duplicate key exception such as

val itemRenderModels = items.map { item ->
    context.child(itemFormula, item)
}

One option to isolate such crashes is providing a special context.child API that has error handling built-in. This would be as such

// Returns a nullable render model instead of a real value in case of an error and fires `onError` callback.
val item: ItemRenderModel? = context.child(itemFormula, item) { error -> Log.e("ItemPage", error) }
@alexanderbezverhni
Copy link
Collaborator

How about we provide a custom lint rule that can be automatically integrated into Formula users' projects? Lint rule that detects key-less context.child() usage within the loop?

@Laimiux
Copy link
Collaborator Author

Laimiux commented Sep 13, 2021

How about we provide a custom lint rule that can be automatically integrated into Formula users' projects? Lint rule that detects key-less context.child() usage within the loop?

I've been exploring lint rules a bit. Currently, I haven't figured out to have such a rule since the key() lives within the Formula. Also, it's hard to catch it if the loop is separated from context.child().

@Laimiux Laimiux closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants