Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ev3dev: replace opaque attribute accessor errors #28

Merged
merged 3 commits into from
Oct 4, 2016
Merged

Conversation

kortschak
Copy link
Member

The design is not finalised, but this makes future changes easier. Methods and types will be exported as necessary.

Updates #24.

@vladimir-ch Please take a look.

@@ -683,14 +683,14 @@ func stateFrom(data, _ string, err error) (MotorState, error) {
for _, s := range strings.Split(data, " ") {
bit, ok := motorStateTable[s]
if !ok {
return 0, fmt.Errorf("ev3dev: unrecognized motor state value: %s in [%s]", s, data)
return 0, newInvalidValueError(d, state, "unrecognized motor state", s, motorStates)
Copy link
Member Author

@kortschak kortschak Oct 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably do something like keys(motorStateTable) in place of motorStates where

func keys(states map[string]MotorState) []string {
    l := make([]string, 0, len(states))
    for k := range states {
        l = append(l, k)
    }
    sort.Strings(l)
    return l
}

because with the current API, it is possible for the user to mutate the motorStates slice.

@kortschak kortschak force-pushed the errors branch 2 times, most recently from 7ef36a9 to dc3b60e Compare October 2, 2016 01:58
@vladimir-ch
Copy link

LGTM

@kortschak kortschak merged commit b434658 into master Oct 4, 2016
@kortschak kortschak deleted the errors branch April 11, 2017 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants