Refactor QPACK encoder and decoder stream errors.

This CL introduces some unused arguments.  The intention is to do as much
refactoring as possible before cl/337315008, with the goal to make both CLs
easier to review.

No behavioral change in production code.

Add some extra information to logs in QPACK roundtrip fuzzer and offline
decoder.

Add QpackEncoderStreamReceiverTest.InvalidHuffmanEncoding and
QpackInstructionDecoderTest.StringLiteralTooLong.

PiperOrigin-RevId: 337654909
Change-Id: Ie7fa54abf264d6906ffd63ef886184c70df3d08d
diff --git a/quic/core/qpack/qpack_decoder.cc b/quic/core/qpack/qpack_decoder.cc
index 9268c9f..67d6a4e 100644
--- a/quic/core/qpack/qpack_decoder.cc
+++ b/quic/core/qpack/qpack_decoder.cc
@@ -74,15 +74,15 @@
   if (is_static) {
     auto entry = header_table_.LookupEntry(/* is_static = */ true, name_index);
     if (!entry) {
-      encoder_stream_error_delegate_->OnEncoderStreamError(
-          "Invalid static table entry.");
+      OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                      "Invalid static table entry.");
       return;
     }
 
     entry = header_table_.InsertEntry(entry->name(), value);
     if (!entry) {
-      encoder_stream_error_delegate_->OnEncoderStreamError(
-          "Error inserting entry with name reference.");
+      OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                      "Error inserting entry with name reference.");
     }
     return;
   }
@@ -90,22 +90,21 @@
   uint64_t absolute_index;
   if (!QpackEncoderStreamRelativeIndexToAbsoluteIndex(
           name_index, header_table_.inserted_entry_count(), &absolute_index)) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Invalid relative index.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR, "Invalid relative index.");
     return;
   }
 
   const QpackEntry* entry =
       header_table_.LookupEntry(/* is_static = */ false, absolute_index);
   if (!entry) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Dynamic table entry not found.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                    "Dynamic table entry not found.");
     return;
   }
   entry = header_table_.InsertEntry(entry->name(), value);
   if (!entry) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Error inserting entry with name reference.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                    "Error inserting entry with name reference.");
   }
 }
 
@@ -113,8 +112,8 @@
                                                 absl::string_view value) {
   const QpackEntry* entry = header_table_.InsertEntry(name, value);
   if (!entry) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Error inserting literal entry.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                    "Error inserting literal entry.");
   }
 }
 
@@ -122,34 +121,35 @@
   uint64_t absolute_index;
   if (!QpackEncoderStreamRelativeIndexToAbsoluteIndex(
           index, header_table_.inserted_entry_count(), &absolute_index)) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Invalid relative index.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR, "Invalid relative index.");
     return;
   }
 
   const QpackEntry* entry =
       header_table_.LookupEntry(/* is_static = */ false, absolute_index);
   if (!entry) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Dynamic table entry not found.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                    "Dynamic table entry not found.");
     return;
   }
   entry = header_table_.InsertEntry(entry->name(), entry->value());
   if (!entry) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Error inserting duplicate entry.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                    "Error inserting duplicate entry.");
   }
 }
 
 void QpackDecoder::OnSetDynamicTableCapacity(uint64_t capacity) {
   if (!header_table_.SetDynamicTableCapacity(capacity)) {
-    encoder_stream_error_delegate_->OnEncoderStreamError(
-        "Error updating dynamic table capacity.");
+    OnErrorDetected(QUIC_QPACK_ENCODER_STREAM_ERROR,
+                    "Error updating dynamic table capacity.");
   }
 }
 
-void QpackDecoder::OnErrorDetected(absl::string_view error_message) {
-  encoder_stream_error_delegate_->OnEncoderStreamError(error_message);
+void QpackDecoder::OnErrorDetected(QuicErrorCode /* error_code */,
+                                   absl::string_view error_message) {
+  encoder_stream_error_delegate_->OnEncoderStreamError(
+      QUIC_QPACK_ENCODER_STREAM_ERROR, error_message);
 }
 
 std::unique_ptr<QpackProgressiveDecoder> QpackDecoder::CreateProgressiveDecoder(