Skip to content

Commit

Permalink
Fix error logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Mar 17, 2021
1 parent 428d163 commit cd73962
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ func (e *Error) Encode() (string, error) {
}

// Decode tries to decode en error from a base64-encoded string
func Decode(str string) (*Error, error) {
func Decode(str string) (*Error, bool) {
bdec, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return nil, err
return nil, false
}

b := bytes.NewReader(bdec)
dec := gob.NewDecoder(b)

var merr Error
if err := dec.Decode(&merr); err != nil {
return nil, err
return nil, false
}

return &merr, nil
return &merr, true
}

func (e *Error) Error() string {
Expand Down
2 changes: 1 addition & 1 deletion transport/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (m *Message) GetError() (err error, hasError bool) {
return nil, false
}

if merr, err := errors.Decode(value); err != nil {
if merr, ok := errors.Decode(value); ok {
return merr, true
}

Expand Down

0 comments on commit cd73962

Please sign in to comment.