Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Jul 29, 2015
1 parent 63d3e2e commit 88dec74
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ type fault struct {
Members []member `xml:"member"`
}

func (f *fault) err() error {
err := &FaultResponseError{}
for _, m := range f.Members {
switch m.Name {
case "faultCode":
err.Code = m.Code
case "faultString":
err.String = m.String
}
}
return err
}

type member struct {
Name string `xml:"name"`
Code int `xml:"value>int"`
Expand Down Expand Up @@ -63,7 +76,6 @@ func (d *decoder) DecodeRequestHeader() (string, error) {
}

d.body = r.Params.Body

return r.MethodName, nil
}

Expand All @@ -76,16 +88,7 @@ func (d *decoder) DecodeResponseHeader() error {
}

if r.Fault != nil {
err := &FaultResponseError{}
for _, m := range r.Fault.Members {
switch m.Name {
case "faultCode":
err.Code = m.Code
case "faultString":
err.String = m.String
}
}
return err
return r.Fault.err()
}

d.body = r.Params.Body
Expand Down

0 comments on commit 88dec74

Please sign in to comment.