Added try-catch for column access with a detailed error messages#1873
Open
AndreiKingsley wants to merge 3 commits into
Open
Added try-catch for column access with a detailed error messages#1873AndreiKingsley wants to merge 3 commits into
AndreiKingsley wants to merge 3 commits into
Conversation
Jolanrensen
requested changes
May 26, 2026
| $columnAccessCode | ||
| } catch (e: Exception) { | ||
| when (e) { | ||
| is IllegalArgumentException -> error(message = "Column not found exception in the generated DataFrame extension property '$renderedColumnName': " + e.getLocalizedMessage() + ". See $troubleshootingLink for more information.") |
Collaborator
There was a problem hiding this comment.
these may require imports, you could put the FQ name here
| /** | ||
| * Generate a try-catch block for column accessor with custom error messages. | ||
| * | ||
| * Catch any exception. Returns an `error()` with a special message. Can be improved with custom exception (#1872). |
Collaborator
There was a problem hiding this comment.
an *IllegalStateException, error() is just the function that triggers it
| when (e) { | ||
| is IllegalArgumentException -> error(message = "Column not found exception in the generated DataFrame extension property '$renderedColumnName': " + e.getLocalizedMessage() + ". See $troubleshootingLink for more information.") | ||
| is ClassCastException -> error(message = "Incorrect column type exception in generated DataFrame extension property '$renderedColumnName': " + e.getLocalizedMessage() + " See $troubleshootingLink for more information.") | ||
| else -> error(message = "Unexpected exception in generated DataFrame extension property '$renderedColumnName'. Please report it to https://github.com/Kotlin/dataframe/issues." + "Exception message: " + e.toString()) |
Collaborator
There was a problem hiding this comment.
it may be better to manually throw the IllegalStateException, because then you can add the cause there
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Library codegen implementation of #1742.
I want to add the same codegen
Can be improved with #1871 and #1872, but for now I added simple different exception handling
error.Requires new doc page from #1870.