Skip to content

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

Open
AndreiKingsley wants to merge 3 commits into
masterfrom
extension_property_errors
Open

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

Conversation

@AndreiKingsley
Copy link
Copy Markdown
Collaborator

@AndreiKingsley AndreiKingsley commented May 25, 2026

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.

@AndreiKingsley AndreiKingsley marked this pull request as ready for review May 25, 2026 14:42
$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.")
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.

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).
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.

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())
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.

it may be better to manually throw the IllegalStateException, because then you can add the cause there

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