On 29/03/2016 20:16, Andrej Golovnin wrote:
177 throw new
IllegalArgumentException(String.valueOf(n));
>>
>>Could you please provide a better message for exception here?
>
>What would the purpose be? It's an internal implementation detail. If this
>exception is thrown, it means it's a bug in the implementation. And I highly
>doubt this error message would be of any help to an end-user. It's not
something
>they can influence/change (most likely).
>What's important here is the stack-trace and te value. Maybe I will include
more
>state to be printed.
A good error message is gold worth. It may save you hours of debugging.
Therefore if you can add more information to the exception message, then please
do it as it will help you to find and to fix bugs faster.
I'd have to agree with Andrej here. Please always consider a decent
exception message and give sustaining/support/end users & other
developers a hint at what happened.
Exception in thread "main" java.lang.IllegalArgumentException:
Negative value encountered in Subscription.request : -1
reads better than :
Exception in thread "main" java.lang.IllegalArgumentException: -1
It'll help in searches and support forums for many years to come *if* a
bug did exist in the implementation. Stacktraces can get lost also.
There seems to be a handful of areas where exception messages could be
improved. Please consider enhancing all "new InternalError()" calls that
have been added/modified :
e.g. : java/net/http/RawChannel.java
! if (!(event instanceof NonBlockingEvent)) {
throw new InternalError();
}
let's print the type of event class received.
Other examples for better messaging :
java/net/http/MessagePublisher.java
+ if ((state & BINARY_EXPECTED) == 0) {
+ throw new IllegalStateException("Unexpected binary message");
+ }
Let's print the state value etc. (even if just to confirm it's a value
we expect) - There are a few other similar areas for improvement which
should be simple enough to find from your webrev.
regards,
Sean.