@DisplayName("from returns CustomRSocketException")
@Test
void fromCustomRSocketException() {

  for (int i = 0; i < 1000; i++) {
    int randomCode =
        ThreadLocalRandom.current().nextBoolean()
            ? ThreadLocalRandom.current()
                .nextInt(Integer.MIN_VALUE, ErrorFrameCodec.MAX_USER_ALLOWED_ERROR_CODE)
            : ThreadLocalRandom.current()
                .nextInt(ErrorFrameCodec.MIN_USER_ALLOWED_ERROR_CODE, Integer.MAX_VALUE);
    ByteBuf byteBuf = createErrorFrame(0, randomCode, "test-message");
    assertThat(Exceptions.from(1, byteBuf))
        .isInstanceOf(CustomRSocketException.class)
        .hasMessage("test-message");
    assertThat(Exceptions.from(0, byteBuf))
        .hasMessage("Invalid Error frame in Stream ID 0: 0x%08X '%s'", randomCode, "test-message")
        .isInstanceOf(IllegalArgumentException.class);
    byteBuf.release();
  }
}