Internal change

PiperOrigin-RevId: 495134833
diff --git a/quiche/quic/core/quic_session.cc b/quiche/quic/core/quic_session.cc
index e71f67f..3355080 100644
--- a/quiche/quic/core/quic_session.cc
+++ b/quiche/quic/core/quic_session.cc
@@ -783,18 +783,23 @@
   connection_->ProcessUdpPacket(self_address, peer_address, packet);
 }
 
+std::string QuicSession::on_closed_frame_string() const {
+  std::stringstream ss;
+  ss << on_closed_frame_;
+  if (source_.has_value()) {
+    ss << " " << ConnectionCloseSourceToString(source_.value());
+  }
+  return ss.str();
+}
+
 QuicConsumedData QuicSession::WritevData(QuicStreamId id, size_t write_length,
                                          QuicStreamOffset offset,
                                          StreamSendingState state,
                                          TransmissionType type,
                                          EncryptionLevel level) {
   QUIC_BUG_IF(session writevdata when disconnected, !connection()->connected())
-      << ENDPOINT
-      << absl::StrCat("Try to write stream data when connection is closed: ",
-                      QuicFrameToString(QuicFrame(&on_closed_frame_)), " ",
-                      source_.has_value()
-                          ? ConnectionCloseSourceToString(source_.value())
-                          : "");
+      << ENDPOINT << "Try to write stream data when connection is closed: "
+      << on_closed_frame_string();
   if (!IsEncryptionEstablished() &&
       !QuicUtils::IsCryptoStreamId(transport_version(), id)) {
     // Do not let streams write without encryption. The calling stream will end
@@ -871,11 +876,8 @@
   QUIC_BUG_IF(quic_bug_12435_11, !connection()->connected())
       << ENDPOINT
       << absl::StrCat("Try to write control frame: ", QuicFrameToString(frame),
-                      " when connection is closed: ",
-                      QuicFrameToString(QuicFrame(&on_closed_frame_)), " ",
-                      source_.has_value()
-                          ? ConnectionCloseSourceToString(source_.value())
-                          : "");
+                      " when connection is closed: ")
+      << on_closed_frame_string();
   if (!IsEncryptionEstablished()) {
     // Suppress the write before encryption gets established.
     return false;
diff --git a/quiche/quic/core/quic_session.h b/quiche/quic/core/quic_session.h
index 2117c8b..ecdabf9 100644
--- a/quiche/quic/core/quic_session.h
+++ b/quiche/quic/core/quic_session.h
@@ -648,6 +648,8 @@
   using ZombieStreamMap =
       absl::flat_hash_map<QuicStreamId, std::unique_ptr<QuicStream>>;
 
+  std::string on_closed_frame_string() const;
+
   // Creates a new stream to handle a peer-initiated stream.
   // Caller does not own the returned stream.
   // Returns nullptr and does error handling if the stream can not be created.