Fix error naming lint in srvdesc.
This commit is contained in:
parent
51ba21d432
commit
1270e56d5f
@ -10,9 +10,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
BadDescriptionError = errors.New("bad XML description")
|
ErrBadDescription = errors.New("bad XML description")
|
||||||
MissingDefinitionError = errors.New("missing definition")
|
ErrMissingDefinition = errors.New("missing definition")
|
||||||
UnsupportedDescriptionError = errors.New("unsupported XML description")
|
ErrUnsupportedDescription = errors.New("unsupported XML description")
|
||||||
)
|
)
|
||||||
|
|
||||||
// SCPD is the top level service description.
|
// SCPD is the top level service description.
|
||||||
@ -37,7 +37,7 @@ func FromXML(xmlDesc *xmlsrvdesc.SCPD) (*SCPD, error) {
|
|||||||
}
|
}
|
||||||
if _, exists := stateVariables[sv.Name]; exists {
|
if _, exists := stateVariables[sv.Name]; exists {
|
||||||
return nil, fmt.Errorf("%w: multiple state variables with name %q",
|
return nil, fmt.Errorf("%w: multiple state variables with name %q",
|
||||||
BadDescriptionError, sv.Name)
|
ErrBadDescription, sv.Name)
|
||||||
}
|
}
|
||||||
stateVariables[sv.Name] = sv
|
stateVariables[sv.Name] = sv
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func FromXML(xmlDesc *xmlsrvdesc.SCPD) (*SCPD, error) {
|
|||||||
}
|
}
|
||||||
if _, exists := actions[action.Name]; exists {
|
if _, exists := actions[action.Name]; exists {
|
||||||
return nil, fmt.Errorf("%w: multiple actions with name %q",
|
return nil, fmt.Errorf("%w: multiple actions with name %q",
|
||||||
BadDescriptionError, action.Name)
|
ErrBadDescription, action.Name)
|
||||||
}
|
}
|
||||||
actions[action.Name] = action
|
actions[action.Name] = action
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ type Action struct {
|
|||||||
// actionFromXML creates an Action from the given XML description.
|
// actionFromXML creates an Action from the given XML description.
|
||||||
func actionFromXML(xmlAction *xmlsrvdesc.Action, scpd *SCPD) (*Action, error) {
|
func actionFromXML(xmlAction *xmlsrvdesc.Action, scpd *SCPD) (*Action, error) {
|
||||||
if xmlAction.Name == "" {
|
if xmlAction.Name == "" {
|
||||||
return nil, fmt.Errorf("%w: empty action name", BadDescriptionError)
|
return nil, fmt.Errorf("%w: empty action name", ErrBadDescription)
|
||||||
}
|
}
|
||||||
action := &Action{
|
action := &Action{
|
||||||
SCPD: scpd,
|
SCPD: scpd,
|
||||||
@ -99,7 +99,7 @@ func actionFromXML(xmlAction *xmlsrvdesc.Action, scpd *SCPD) (*Action, error) {
|
|||||||
outArgs = append(outArgs, arg)
|
outArgs = append(outArgs, arg)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("%w: argument %q has invalid direction %q",
|
return nil, fmt.Errorf("%w: argument %q has invalid direction %q",
|
||||||
BadDescriptionError, xmlArg.Name, xmlArg.Direction)
|
ErrBadDescription, xmlArg.Name, xmlArg.Direction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
action.InArgs = inArgs
|
action.InArgs = inArgs
|
||||||
@ -117,10 +117,10 @@ type Argument struct {
|
|||||||
// argumentFromXML creates an Argument from the XML description.
|
// argumentFromXML creates an Argument from the XML description.
|
||||||
func argumentFromXML(xmlArg *xmlsrvdesc.Argument, action *Action) (*Argument, error) {
|
func argumentFromXML(xmlArg *xmlsrvdesc.Argument, action *Action) (*Argument, error) {
|
||||||
if xmlArg.Name == "" {
|
if xmlArg.Name == "" {
|
||||||
return nil, fmt.Errorf("%w: empty argument name", BadDescriptionError)
|
return nil, fmt.Errorf("%w: empty argument name", ErrBadDescription)
|
||||||
}
|
}
|
||||||
if xmlArg.RelatedStateVariable == "" {
|
if xmlArg.RelatedStateVariable == "" {
|
||||||
return nil, fmt.Errorf("%w: empty related state variable", BadDescriptionError)
|
return nil, fmt.Errorf("%w: empty related state variable", ErrBadDescription)
|
||||||
}
|
}
|
||||||
return &Argument{
|
return &Argument{
|
||||||
Action: action,
|
Action: action,
|
||||||
@ -133,7 +133,7 @@ func (arg *Argument) RelatedStateVariable() (*StateVariable, error) {
|
|||||||
if v, ok := arg.Action.SCPD.VariableByName[arg.RelatedStateVariableName]; ok {
|
if v, ok := arg.Action.SCPD.VariableByName[arg.RelatedStateVariableName]; ok {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("%w: state variable %q", MissingDefinitionError, arg.RelatedStateVariableName)
|
return nil, fmt.Errorf("%w: state variable %q", ErrMissingDefinition, arg.RelatedStateVariableName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StateVariable description data.
|
// StateVariable description data.
|
||||||
@ -144,11 +144,11 @@ type StateVariable struct {
|
|||||||
|
|
||||||
func stateVariableFromXML(xmlSV *xmlsrvdesc.StateVariable) (*StateVariable, error) {
|
func stateVariableFromXML(xmlSV *xmlsrvdesc.StateVariable) (*StateVariable, error) {
|
||||||
if xmlSV.Name == "" {
|
if xmlSV.Name == "" {
|
||||||
return nil, fmt.Errorf("%w: empty state variable name", BadDescriptionError)
|
return nil, fmt.Errorf("%w: empty state variable name", ErrBadDescription)
|
||||||
}
|
}
|
||||||
if xmlSV.DataType.Type != "" {
|
if xmlSV.DataType.Type != "" {
|
||||||
return nil, fmt.Errorf("%w: unsupported data type %q",
|
return nil, fmt.Errorf("%w: unsupported data type %q",
|
||||||
UnsupportedDescriptionError, xmlSV.DataType.Type)
|
ErrUnsupportedDescription, xmlSV.DataType.Type)
|
||||||
}
|
}
|
||||||
return &StateVariable{
|
return &StateVariable{
|
||||||
Name: xmlSV.Name,
|
Name: xmlSV.Name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user