API 테스트 에러처리 수정

This commit is contained in:
현성필
2023-10-17 14:06:13 +09:00
parent 75137553fe
commit 5ab8969827
@@ -98,6 +98,16 @@ public class NettyApiClient {
ch.writeAndFlush(request);
ch.closeFuture().sync();
} catch (Exception e) {
ApiResponse response = new ApiResponse();
if (e instanceof java.net.UnknownHostException) {
response.setStatus(404);
response.setBody("Unknown host: " + e.getMessage());
} else {
response.setStatus(500);
response.setBody("An error occurred: " + e.getMessage());
}
return CompletableFuture.completedFuture(response);
} finally {
group.shutdownGracefully();
}