pw_rpc: Don't respond to error messages

Servers and client should never send errors in response to other errors.
Doing so could result in an infinite cycle of error packets.

Change-Id: If70f06fdcbd62b386a6103b532182314ec5face0
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/60447
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_rpc/client.cc b/pw_rpc/client.cc
index ead04c1..f8c1b29 100644
--- a/pw_rpc/client.cc
+++ b/pw_rpc/client.cc
@@ -62,8 +62,11 @@
 
   if (call == calls_.end()) {
     PW_LOG_WARN("RPC client received a packet for a request it did not make");
-    channel->Send(Packet::ClientError(packet, Status::FailedPrecondition()))
-        .IgnoreError();  // TODO(pwbug/387): Handle Status properly
+    // Don't send responses to errors to avoid infinite error cycles.
+    if (packet.type() != PacketType::SERVER_ERROR) {
+      channel->Send(Packet::ClientError(packet, Status::FailedPrecondition()))
+          .IgnoreError();
+    }
     return Status::NotFound();
   }