Skip to content

Commit

Permalink
fix: Convert some more panics to errors messages
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeernaertProton committed Sep 1, 2022
1 parent ccc6245 commit 6df22db
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions internal/session/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package session

import (
"context"
"fmt"
"runtime/pprof"
"strconv"

Expand Down Expand Up @@ -87,7 +88,7 @@ func (s *Session) handleCommand(
return s.handleSelectedCommand(ctx, tag, cmd, ch, profiler)

default:
panic("bad command")
return fmt.Errorf("bad command")
}
}

Expand Down Expand Up @@ -121,7 +122,7 @@ func (s *Session) handleAnyCommand(
return s.handleIDGet(ctx, tag, ch)

default:
panic("bad command")
return fmt.Errorf("bad command")
}
}

Expand All @@ -144,7 +145,7 @@ func (s *Session) handleNotAuthenticatedCommand(
return s.handleLogin(ctx, tag, cmd.GetLogin(), ch)

default:
panic("bad command")
return fmt.Errorf("bad command")
}
}

Expand Down Expand Up @@ -230,7 +231,7 @@ func (s *Session) handleAuthenticatedCommand(
return s.handleAppend(ctx, tag, cmd.GetAppend(), ch)

default:
panic("bad command")
return fmt.Errorf("bad command")
}
}

Expand Down Expand Up @@ -336,6 +337,6 @@ func (s *Session) handleWithMailbox(
return s.handleMove(ctx, tag, cmd.GetMove(), mailbox, ch)

default:
panic("bad command")
return fmt.Errorf("bad command")
}
}

0 comments on commit 6df22db

Please sign in to comment.