return new ErrorMessage((TransportException)e, streamId); logger.error("Unexpected exception during request", e); return new ErrorMessage(new ServerError(e), streamId);
public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
private ErrorMessage(TransportException error, int streamId) { this(error); setStreamId(streamId); }
private void fail() { // Reset to the initial state and throw the exception long tooLongFrameLength = this.tooLongFrameLength; this.tooLongFrameLength = 0; discardingTooLongFrame = false; String msg = String.format("Request is too big: length %d exceeds maximum allowed length %d.", tooLongFrameLength, MAX_FRAME_LENGTH); throw ErrorMessage.wrap(new InvalidRequestException(msg), tooLongStreamId); } }
@Override public void channelRead0(ChannelHandlerContext ctx, Request request) { final Response response; final ServerConnection connection; try { assert request.connection() instanceof ServerConnection; connection = (ServerConnection)request.connection(); QueryState qstate = connection.validateNewMessage(request.type, connection.getVersion(), request.getStreamId()); logger.debug("Received: {}, v={}", request, connection.getVersion()); response = request.execute(qstate); response.setStreamId(request.getStreamId()); response.attach(connection); connection.applyStateTransition(request.type, response.type); } catch (Throwable t) { JVMStabilityInspector.inspectThrowable(t); UnexpectedChannelExceptionHandler handler = new UnexpectedChannelExceptionHandler(ctx.channel(), true); flush(new FlushItem(ctx, ErrorMessage.fromException(t, handler).setStreamId(request.getStreamId()), request.getSourceFrame())); return; } logger.debug("Responding: {}, v={}", response, connection.getVersion()); flush(new FlushItem(ctx, response, request.getSourceFrame())); }
private static TransportException getBackwardsCompatibleException(ErrorMessage msg, ProtocolVersion version) { if (version.isSmallerThan(ProtocolVersion.V4)) { switch (msg.error.code()) { case READ_FAILURE: ReadFailureException rfe = (ReadFailureException) msg.error; return new ReadTimeoutException(rfe.consistency, rfe.received, rfe.blockFor, rfe.dataPresent); case WRITE_FAILURE: WriteFailureException wfe = (WriteFailureException) msg.error; return new WriteTimeoutException(wfe.writeType, wfe.consistency, wfe.received, wfe.blockFor); case FUNCTION_FAILURE: return new InvalidRequestException(msg.toString()); } } return msg.error; }
private void fail() { // Reset to the initial state and throw the exception long tooLongFrameLength = this.tooLongFrameLength; this.tooLongFrameLength = 0; discardingTooLongFrame = false; String msg = String.format("Request is too big: length %d exceeds maximum allowed length %d.", tooLongFrameLength, MAX_FRAME_LENGTH); throw ErrorMessage.wrap(new InvalidRequestException(msg), tooLongStreamId); } }
flush(new FlushItem(ctx, ErrorMessage.fromException(t, handler).setStreamId(request.getStreamId()), request.getSourceFrame())); return;
private static TransportException getBackwardsCompatibleException(ErrorMessage msg, ProtocolVersion version) { if (version.isSmallerThan(ProtocolVersion.V4)) { switch (msg.error.code()) { case READ_FAILURE: ReadFailureException rfe = (ReadFailureException) msg.error; return new ReadTimeoutException(rfe.consistency, rfe.received, rfe.blockFor, rfe.dataPresent); case WRITE_FAILURE: WriteFailureException wfe = (WriteFailureException) msg.error; return new WriteTimeoutException(wfe.writeType, wfe.consistency, wfe.received, wfe.blockFor); case FUNCTION_FAILURE: return new InvalidRequestException(msg.toString()); } } return msg.error; }
public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
private void fail() { // Reset to the initial state and throw the exception long tooLongFrameLength = this.tooLongFrameLength; this.tooLongFrameLength = 0; discardingTooLongFrame = false; String msg = String.format("Request is too big: length %d exceeds maximum allowed length %d.", tooLongFrameLength, MAX_FRAME_LENGTH); throw ErrorMessage.wrap(new InvalidRequestException(msg), tooLongStreamId); } }
flush(new FlushItem(ctx, ErrorMessage.fromException(t, handler).setStreamId(request.getStreamId()), request.getSourceFrame())); return;
private ErrorMessage(TransportException error, int streamId) { this(error); setStreamId(streamId); }
ErrorMessage message = new ErrorMessage((TransportException) e, streamId); if (e instanceof ProtocolException) logger.error("Unexpected exception during request", e); return new ErrorMessage(new ServerError(e), streamId);
private static TransportException getBackwardsCompatibleException(ErrorMessage msg, ProtocolVersion version) { if (version.isSmallerThan(ProtocolVersion.V4)) { switch (msg.error.code()) { case READ_FAILURE: ReadFailureException rfe = (ReadFailureException) msg.error; return new ReadTimeoutException(rfe.consistency, rfe.received, rfe.blockFor, rfe.dataPresent); case WRITE_FAILURE: WriteFailureException wfe = (WriteFailureException) msg.error; return new WriteTimeoutException(wfe.writeType, wfe.consistency, wfe.received, wfe.blockFor); case FUNCTION_FAILURE: return new InvalidRequestException(msg.toString()); } } return msg.error; }
public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
private void fail() { // Reset to the initial state and throw the exception long tooLongFrameLength = this.tooLongFrameLength; this.tooLongFrameLength = 0; discardingTooLongFrame = false; String msg = String.format("Request is too big: length %d exceeds maximum allowed length %d.", tooLongFrameLength, MAX_FRAME_LENGTH); throw ErrorMessage.wrap(new InvalidRequestException(msg), tooLongStreamId); } }
flush(new FlushItem(ctx, ErrorMessage.fromException(t, handler).setStreamId(request.getStreamId()), request.getSourceFrame())); return;
private ErrorMessage(TransportException error, int streamId) { this(error); setStreamId(streamId); }
ErrorMessage message = new ErrorMessage((TransportException) e, streamId); if (e instanceof ProtocolException) logger.error("Unexpected exception during request", e); return new ErrorMessage(new ServerError(e), streamId);