Skip to content

Commit

Permalink
Merge pull request #725 from rqlite/better-command-decode-panic
Browse files Browse the repository at this point in the history
Better command decoding panic message
  • Loading branch information
otoolep committed Jan 5, 2021
2 parents 9ca75f3 + 4f0c309 commit 10a24cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions command/legacy/command.go
Expand Up @@ -17,10 +17,10 @@ const (

var (
// ErrNotLegacyCommand is returned when a command is not legacy encoded.
ErrNotLegacyCommand = errors.New("not legacy command")
ErrNotLegacyCommand = errors.New("not legacy JSON-encoded command")

// ErrUnknownCommandType is returned when an unknown command type is encountered.
ErrUnknownCommandType = errors.New("unknown command type")
ErrUnknownCommandType = errors.New("unknown JSON-encoded command type")

// ErrUnsupportedType is returned when a request contains an unsupported type.
ErrUnsupportedType = errors.New("unsupported type")
Expand Down
4 changes: 2 additions & 2 deletions store/store.go
Expand Up @@ -854,8 +854,8 @@ func (s *Store) Apply(l *raft.Log) interface{} {
var c command.Command

if err := legacy.Unmarshal(l.Data, &c); err != nil {
if err = command.Unmarshal(l.Data, &c); err != nil {
panic(fmt.Sprintf("failed to unmarshal cluster command: %s", err.Error()))
if err2 := command.Unmarshal(l.Data, &c); err2 != nil {
panic(fmt.Sprintf("failed to unmarshal cluster command: %s (legacy unmarshal: %s)", err2.Error(), err.Error()))
}
}

Expand Down

0 comments on commit 10a24cf

Please sign in to comment.