public void logReplaySessionError(final long sessionId, final long recordingId, final String errorMessage)
    {
        final int length = SIZE_OF_LONG * 2 + SIZE_OF_INT + errorMessage.length();
        final int captureLength = captureLength(length);
        final int encodedLength = encodedLength(captureLength);
        final ManyToOneRingBuffer ringBuffer = this.ringBuffer;
        final int index = ringBuffer.tryClaim(REPLAY_SESSION_ERROR.toEventCodeId(), encodedLength);

        if (index > 0)
        {
            try
            {
                encodeReplaySessionError(
                    (UnsafeBuffer)ringBuffer.buffer(),
                    index,
                    captureLength,
                    length,
                    sessionId,
                    recordingId,
                    errorMessage);
            }
            finally
            {
                ringBuffer.commit(index);
            }
        }
    }
@Test
    void logReplaySessionError()
    {
        final int offset = ALIGNMENT * 5 + 128;
        logBuffer.putLong(CAPACITY + TAIL_POSITION_OFFSET, offset);
        final long sessionId = 123;
        final long recordingId = Long.MIN_VALUE;
        final String errorMessage = "the error";
        final int captureLength = SIZE_OF_LONG * 2 + SIZE_OF_INT + errorMessage.length();

        logger.logReplaySessionError(sessionId, recordingId, errorMessage);

        verifyLogHeader(logBuffer, offset, REPLAY_SESSION_ERROR.toEventCodeId(), captureLength, captureLength);
        assertEquals(sessionId, logBuffer.getLong(encodedMsgOffset(offset + LOG_HEADER_LENGTH), LITTLE_ENDIAN));
        assertEquals(recordingId,
            logBuffer.getLong(encodedMsgOffset(offset + LOG_HEADER_LENGTH + SIZE_OF_LONG), LITTLE_ENDIAN));
        assertEquals(errorMessage,
            logBuffer.getStringAscii(encodedMsgOffset(offset + LOG_HEADER_LENGTH + SIZE_OF_LONG * 2)));
    }