下面列出了怎么用io.netty.channel.unix.Errors.NativeIoException的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public Mono<Void> handle(final ServerWebExchange exchange, final Throwable throwable) {
if (throwable instanceof ConnectException
|| throwable instanceof NativeIoException
|| throwable instanceof NotFoundException) {
LOG.error("ConnectException thrown", throwable);
return doHandle(exchange, throwable, HttpStatus.NOT_FOUND);
} else if (throwable instanceof OAuth2AuthorizationException) {
LOG.error("OAuth2AuthorizationException thrown", throwable);
return doHandle(exchange, throwable, HttpStatus.INTERNAL_SERVER_ERROR);
}
return Mono.error(throwable);
}
@Override
protected void assertRstOnCloseException(IOException cause, Channel clientChannel) {
if (!AbstractKQueueChannel.class.isInstance(clientChannel)) {
super.assertRstOnCloseException(cause, clientChannel);
return;
}
assertTrue("actual [type, message]: [" + cause.getClass() + ", " + cause.getMessage() + "]",
cause instanceof NativeIoException);
assertEquals(Errors.ERRNO_ECONNRESET_NEGATIVE, ((NativeIoException) cause).expectedErr());
}
@Override
protected void assertRstOnCloseException(IOException cause, Channel clientChannel) {
if (!AbstractEpollChannel.class.isInstance(clientChannel)) {
super.assertRstOnCloseException(cause, clientChannel);
return;
}
assertTrue("actual [type, message]: [" + cause.getClass() + ", " + cause.getMessage() + "]",
cause instanceof NativeIoException);
assertEquals(Errors.ERRNO_ECONNRESET_NEGATIVE, ((NativeIoException) cause).expectedErr());
}
public static boolean isKnownException(Throwable t) {
return t instanceof NativeIoException || t instanceof ClosedChannelException;
}