Skip to content

Added try-catch for column access with a detailed error messages#1873

Open
AndreiKingsley wants to merge 6 commits into
masterfrom
extension_property_errors
Open

Added try-catch for column access with a detailed error messages#1873
AndreiKingsley wants to merge 6 commits into
masterfrom
extension_property_errors

Conversation

@AndreiKingsley

@AndreiKingsley AndreiKingsley commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Library codegen implementation of #1742.

I want to add the same codegen to Compiler Plugin.

Can be improved with #1871 and #1872, but for now I added simple different exception handling error.

Requires new doc page from #1870.

@AndreiKingsley AndreiKingsley marked this pull request as ready for review May 25, 2026 14:42
$columnAccessCode
} catch (e: kotlin.Exception) {
val msg = when (e) {
is kotlin.IllegalArgumentException -> "Column not found exception in the generated DataFrame extension property '$renderedColumnName': " + e.getLocalizedMessage() + ". See $troubleshootingLink for more information."

@Jolanrensen Jolanrensen Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you mix string templates and + here, actually? Just curious :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me just better readability. But let's be consistent and idiomatic, ok.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also use a string builder if that looks more readable :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote with better templates!

@Jolanrensen

Copy link
Copy Markdown
Collaborator

you've got some failing tests :)

@AndreiKingsley

Copy link
Copy Markdown
Collaborator Author

@Jolanrensen this PR is not supposed to me merged (most probably) — @koperagen doesn't want to change EP logic on library side, but I need you review on it because it's much easier to review it here rather then in Compiler Plugin.

*/
private fun generateTryCatchColumnAccess(columnAccessCode: String, columnName: String): String {
val renderedColumnName = renderStringLiteral(columnName)
return $$"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice $$ usage :) but can you indent the code a bit further to the right? It's currently left of the return. Also if you assign it to a variable first, you can annotate it with @Language("kotlin") which might be nice

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

Successfully merging this pull request may close these issues.

2 participants