Skip to content

Commit 91c822a

Browse files
committed
added better error handling
1 parent 0a2722f commit 91c822a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/in/erail/route/OpenAPI3RouteBuilder.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727
import io.vertx.core.json.JsonArray;
2828
import io.vertx.reactivex.core.buffer.Buffer;
2929
import io.vertx.reactivex.ext.web.Cookie;
30-
import java.util.ArrayList;
3130
import java.util.Arrays;
3231
import java.util.HashMap;
3332
import java.util.Iterator;
34-
import java.util.List;
3533
import java.util.Optional;
3634

3735
/**
@@ -181,7 +179,14 @@ public HttpServerResponse buildResponseFromReply(JsonObject pReplyResponse, Rout
181179
}
182180
});
183181

184-
Optional<byte[]> body = Optional.ofNullable(pReplyResponse.getBinary(Json.BODY));
182+
Optional<byte[]> body;
183+
184+
try {
185+
body = Optional.ofNullable(pReplyResponse.getBinary(Json.BODY));
186+
} catch (IllegalArgumentException e) {
187+
getLog().error(() -> "Could not get message body as binary. Please check if service is sending body in binary." + pContext.request().absoluteURI() + ":" + e.toString());
188+
body = Optional.empty();
189+
}
185190

186191
body.ifPresent((t) -> {
187192
pContext.response().putHeader(HttpHeaderNames.CONTENT_LENGTH.toString(), Integer.toString(t.length));

0 commit comments

Comments
 (0)