Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
use switch statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Skelcy committed Mar 30, 2018
1 parent f49c48f commit 8158bb6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type ValidationError string
func NewValidationError(str string) error { return ValidationError(str) }
func (e ValidationError) Error() string { return string(e) }

// StaleDataError is returned when a rule is modified but the
// underlying data has changed and the rquest is no longer valid.
// StaleDataError is returned when a rule modification is attempted but the
// underlying data has changed and the change is no longer valid.
type StaleDataError string

// NewStaleDataError creates a new version mismatch error.
Expand Down
10 changes: 5 additions & 5 deletions rules/store/kv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ func (s *store) WriteRuleSet(rs rules.MutableRuleSet) error {
}
conditions, ops := []kv.Condition{rsCond}, []kv.Op{rsOp}
_, err = s.kvStore.Commit(conditions, ops)
if err != nil {
if err == kv.ErrConditionCheckFailed {
err = merrors.NewStaleDataError(err.Error())
}
switch err {
case kv.ErrConditionCheckFailed:
return merrors.NewStaleDataError(err.Error())
default:
return err
}
return err
}

func (s *store) WriteAll(nss *rules.Namespaces, rs rules.MutableRuleSet) error {
Expand Down

0 comments on commit 8158bb6

Please sign in to comment.