From eb9141cbf5be78231c510c3c8278cdc8d81f5002 Mon Sep 17 00:00:00 2001 From: Dmitry Kropachev Date: Fri, 20 Dec 2024 09:29:46 -0400 Subject: [PATCH] Don't panic on unknown error Currently driver panics on unknown error. It is better to return generic error with maximum available information in it. --- errors.go | 4 ++++ frame.go | 4 +++- frame_test.go | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/errors.go b/errors.go index 4fb372683..bafaab6ff 100644 --- a/errors.go +++ b/errors.go @@ -197,6 +197,10 @@ type RequestErrCASWriteUnknown struct { BlockFor int } +type UnknownServerError struct { + errorFrame +} + type OpType uint8 const ( diff --git a/frame.go b/frame.go index d7e6b8dc4..8d82d4b4f 100644 --- a/frame.go +++ b/frame.go @@ -723,7 +723,9 @@ func (f *framer) parseErrorFrame() frame { res.RejectedByCoordinator = f.readByte() != 0 return res } else { - panic(fmt.Errorf("unknown error code: 0x%x", errD.code)) + return &UnknownServerError{ + errorFrame: errD, + } } } } diff --git a/frame_test.go b/frame_test.go index 28cc783b3..29da03b37 100644 --- a/frame_test.go +++ b/frame_test.go @@ -25,8 +25,6 @@ func TestFuzzBugs(t *testing.T) { "0000000"), []byte("\x82\xe600\x00\x00\x00\x000"), []byte("\x8200\b\x00\x00\x00\b0\x00\x00\x00\x040000"), - []byte("\x8200\x00\x00\x00\x00\x100\x00\x00\x12\x00\x00\x0000000" + - "00000"), []byte("\x83000\b\x00\x00\x00\x14\x00\x00\x00\x020000000" + "000000000"), []byte("\x83000\b\x00\x00\x000\x00\x00\x00\x04\x00\x1000000" +