|
1 | 1 | package com.beowulfe.hap.impl.http.impl; |
2 | 2 |
|
| 3 | +import com.beowulfe.hap.impl.http.HomekitClientConnection; |
| 4 | +import com.beowulfe.hap.impl.http.HomekitClientConnectionFactory; |
| 5 | +import com.beowulfe.hap.impl.http.HttpResponse; |
3 | 6 | import io.netty.buffer.Unpooled; |
4 | | -import io.netty.channel.*; |
| 7 | +import io.netty.channel.Channel; |
| 8 | +import io.netty.channel.ChannelHandlerContext; |
| 9 | +import io.netty.channel.ChannelPipeline; |
| 10 | +import io.netty.channel.SimpleChannelInboundHandler; |
5 | 11 | import io.netty.handler.codec.http.*; |
6 | | - |
7 | | -import java.nio.charset.StandardCharsets; |
8 | | - |
9 | 12 | import org.slf4j.Logger; |
10 | 13 | import org.slf4j.LoggerFactory; |
11 | 14 |
|
12 | | -import com.beowulfe.hap.impl.http.*; |
13 | | -import com.beowulfe.hap.impl.http.HttpResponse; |
| 15 | +import java.io.IOException; |
| 16 | +import java.nio.charset.StandardCharsets; |
14 | 17 |
|
15 | 18 | class AccessoryHandler extends SimpleChannelInboundHandler<FullHttpRequest> { |
16 | 19 |
|
@@ -84,7 +87,16 @@ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { |
84 | 87 | @Override |
85 | 88 | public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) |
86 | 89 | throws Exception { |
87 | | - LOGGER.error("Exception caught in web handler", cause); |
| 90 | + boolean errorLevel = true; |
| 91 | + if (cause instanceof IOException) { |
| 92 | + // Decide level of logging based on exception |
| 93 | + errorLevel = !"Connection timed out".equals(cause.getMessage()); |
| 94 | + } |
| 95 | + if (errorLevel) { |
| 96 | + LOGGER.error("Exception caught in web handler", cause); |
| 97 | + } else { |
| 98 | + LOGGER.debug("Exception caught in web handler", cause); |
| 99 | + } |
88 | 100 | ctx.close(); |
89 | 101 | } |
90 | 102 | } |
0 commit comments