From 947cede88aa17943194106cceff84e15120e04db Mon Sep 17 00:00:00 2001 From: tycho garen Date: Mon, 21 Mar 2022 11:47:58 -0400 Subject: [PATCH] narrow panics --- internal/consensus/state.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/consensus/state.go b/internal/consensus/state.go index b8c0bd2be..5fbb0fb00 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -875,9 +875,9 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) { return } - // don't re-panic if we're already trying to - // shut down - if ctx.Err() != nil { + // don't re-panic if the panic is just an + // error and we're already trying to shut down + if _, ok := r.(error); ok && ctx.Err() != nil { return } panic(r) @@ -909,9 +909,9 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) { case mi := <-cs.internalMsgQueue: err := cs.wal.WriteSync(mi) // NOTE: fsync if err != nil { - panic(fmt.Errorf( - "failed to write %v msg to consensus WAL due to %w; check your file system and restart the node", - mi, err, + panic(fmt.Sprintf( + "failed to write %v msg to consensus WAL due to %q; check your file system and restart the node", + mi, err.Error(), )) }