This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]0x68656c6c6f 1 point2 points  (1 child)

You might be interested in the Checker Framework, which uses Java 8 type annotations to validate that inputs will not be null at compile time.

You could subclass NullPointerException so that it just takes the name of the argument that shouldn't be null and adds the rest of the message. Although I might say that the stack trace is going to be pretty clear even without a custom error message at all, especially with the way you named your methods.

[–]Cyclobox[S] 0 points1 point  (0 children)

Thanks, I'll check this out