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

Make null param error more informative (#809) #2142

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

ulfryk
Copy link
Contributor

@ulfryk ulfryk commented Nov 20, 2024

Same as #2141 but in the simplest possible manner.

@@ -56,7 +56,7 @@ sealed abstract class Put[A](
) {}

def unsafeSetNonNullable(ps: PreparedStatement, n: Int, a: A): Unit =
if (a == null) sys.error("oops, null")
if (a == null) sys.error("Expected non-nullable param. Use Option to describe nullable values.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks nice and simple :)
We can put n into the error message to provide an even friendlier error message. Since this is all under the if clause we won't pay the cost of constructing the string until the null case is encountered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@ulfryk ulfryk force-pushed the fix/uninformative-null-error-simple branch from 55193d6 to aab920f Compare November 22, 2024 00:28
@jatcwang jatcwang merged commit 472eb3e into typelevel:main Nov 22, 2024
5 checks passed
@jatcwang
Copy link
Collaborator

Thanks a lot! 😄

@ulfryk ulfryk deleted the fix/uninformative-null-error-simple branch November 22, 2024 09:59
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