Add state in exception message (#10842)

Motivation:
We should add `state` in the exception message of `HttpObjectEncoder` because it makes debugging a little easier.

Modification:
Added `state` in the exception message.

Result:
Better exception message for smooth debugging.
This commit is contained in:
Aayush Atharva 2020-12-07 15:19:09 +05:30 committed by GitHub
parent f551db2bda
commit abd5a7d922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,7 +121,8 @@ public abstract class HttpObjectEncoder<H extends HttpMessage> extends MessageTo
if (msg instanceof HttpContent || msg instanceof ByteBuf || msg instanceof FileRegion) { if (msg instanceof HttpContent || msg instanceof ByteBuf || msg instanceof FileRegion) {
switch (state) { switch (state) {
case ST_INIT: case ST_INIT:
throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg)); throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg)
+ ", state: " + state);
case ST_CONTENT_NON_CHUNK: case ST_CONTENT_NON_CHUNK:
final long contentLength = contentLength(msg); final long contentLength = contentLength(msg);
if (contentLength > 0) { if (contentLength > 0) {