public void exceptionEvent(ExceptionEvent event) { ObjectReference or = event.exception(); ReferenceType rt = or.referenceType(); String exceptionName = rt.name(); // Field messageField = Throwable.class.getField("detailMessage"); Field messageField = rt.fieldByName("detailMessage"); // System.out.println("field " + messageField); Value messageValue = or.getValue(messageField); // System.out.println("mess val " + messageValue); // "java.lang.ArrayIndexOutOfBoundsException" int last = exceptionName.lastIndexOf('.'); String message = exceptionName.substring(last + 1); if (messageValue != null) { String messageStr = messageValue.toString(); if (messageStr.startsWith("\"")) { messageStr = messageStr.substring(1, messageStr.length() - 1); } message += ": " + messageStr; } // System.out.println("mess type " + messageValue.type()); // StringReference messageReference = (StringReference) messageValue.type(); // First just report the exception and its placement reportException(message, or, event.thread()); // Then try to pretty it up with a better message handleCommonErrors(exceptionName, message, listener); if (editor != null) { editor.deactivateRun(); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channel ch = e.getChannel(); Throwable cause = e.getCause(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } if (cause != null) { if (cause.getClass().equals(IOException.class)) { LOGGER.debug("Connection error: " + cause); StartStopListenerDelegate startStopListenerDelegate = (StartStopListenerDelegate) ctx.getAttachment(); if (startStopListenerDelegate != null) { LOGGER.debug("Premature end, stopping..."); startStopListenerDelegate.stop(); } } else if (!cause.getClass().equals(ClosedChannelException.class)) { LOGGER.debug("Caught exception: " + cause); } } if (ch.isConnected()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } e.getChannel().close(); }
protected void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (e.getCause() instanceof ReadTimeoutException) { if (logger.isTraceEnabled()) { logger.trace("Connection timeout [{}]", ctx.getChannel().getRemoteAddress()); } ctx.getChannel().close(); } else { if (!lifecycle.started()) { // ignore return; } if (!NetworkExceptionHelper.isCloseConnectionException(e.getCause())) { logger.warn( "Caught exception while handling client http traffic, closing connection {}", e.getCause(), ctx.getChannel()); ctx.getChannel().close(); } else { logger.debug( "Caught exception while handling client http traffic, closing connection {}", e.getCause(), ctx.getChannel()); ctx.getChannel().close(); } } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (e.getCause() instanceof JsonParseException) { BaseTransport.respond( e.getChannel(), HttpResponseStatus.INTERNAL_SERVER_ERROR, "Broken JSON encoding."); } else if (e.getCause() instanceof SessionHandler.NotFoundException) { BaseTransport.respond( e.getChannel(), HttpResponseStatus.NOT_FOUND, "Session not found. Cannot send data to non-existing session."); } else { super.exceptionCaught(ctx, e); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channel ch = e.getChannel(); Throwable cause = e.getCause(); if (cause instanceof TooLongFrameException) { sendError(ctx, BAD_REQUEST); return; } cause.printStackTrace(); if (ch.isConnected()) { sendError(ctx, INTERNAL_SERVER_ERROR); } }
public void dispatchEvent(Event event) { // TODO: Add pluggable support for event formatters if (event instanceof ExceptionEvent) { ExceptionEvent exceptionEvent = (ExceptionEvent) event; monitorLog.info(event.getShortMessage(), exceptionEvent.getThrowable()); } else { monitorLog.info( event.getClass().getName() + ":" + event.getShortMessage() + ":" + event.getLongMessage()); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { // На канале произошло исключение. Выводим ошибку, закрываем канал. // Server.logger.log(Level.WARNING, "Exception from downstream", e.getCause()); ctx.getChannel().close(); log.info("exceptionCaught", e.getCause()); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) { Throwable cause = event.getCause(); if (!(cause instanceof ConnectException)) { LOG.info("Connection failed " + client.dstAddressPrefixedName, cause); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { try { e.getChannel().close(); } catch (Exception ex) { } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channel ch = e.getChannel(); Throwable cause = e.getCause(); if (cause instanceof TooLongFrameException) { sendError(ctx, HttpResponseStatus.BAD_REQUEST); return; } if (cause != null && !cause.getClass().equals(ClosedChannelException.class) && !cause.getClass().equals(IOException.class)) { LOGGER.debug("Caught exception", cause); } if (ch.isConnected()) { sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR); } e.getChannel().close(); }
/** Invoked when an exception was raised by an I/O thread or a {@link ChannelHandler}. */ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { if (this == ctx.getPipeline().getLast()) { logger.warn( "EXCEPTION, please implement " + getClass().getName() + ".exceptionCaught() for proper handling.", e.getCause()); } ctx.sendUpstream(e); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Channel channel = ctx.getChannel(); if (channel.getAttachment() != null && (Error.class.isAssignableFrom(channel.getAttachment().getClass()) || WRITING.equals(channel.getAttachment().toString()))) { return; } if (!isReceived(ctx)) { return; } try { log.error(e.getCause().getMessage(), e.getCause()); channel.setAttachment(new Error()); DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR); response.setContent( ChannelBuffers.copiedBuffer( response.getStatus().toString() + ":" + e.getCause().getMessage(), CharsetUtil.UTF_8)); response.headers().set(Names.CONTENT_LENGTH, response.getContent().readableBytes()); response.headers().set(Names.SERVER, "NAVI/1.1.4(UNIX)"); response.headers().set(Names.CONNECTION, "close"); ChannelFuture f = channel.write(response); f.addListener(ChannelFutureListener.CLOSE); f.addListener( new ChannelFutureListener() { public void operationComplete(ChannelFuture f) throws Exception { if (!f.isSuccess()) { log.error(f.getCause().getMessage(), f.getCause()); } } }); } catch (Exception ex) { log.error(e.getCause().getMessage(), e.getCause()); e.getFuture().addListener(ChannelFutureListener.CLOSE); } }
/** * Interface method implementation. Closes the underlying channel after logging a warning message * * @see * org.jboss.netty.channel.SimpleChannelHandler#exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext, * org.jboss.netty.channel.ExceptionEvent) */ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent event) throws Exception { LOGGER.warn( "Exception {} thrown on Channel {}. Disconnect initiated", event, event.getChannel()); event.getCause().printStackTrace(); event.getChannel().close(); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { // Close the connection when an exception is raised. e.getCause().printStackTrace(); e.getChannel().close(); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) { e.getCause().printStackTrace(); e.getChannel().close(); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { netHandler.exceptionCaught((Session) ctx.getAttachment(), e.getCause()); }