mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-22 16:24:14 +00:00
internal: add more context to Response.DecodeProp errors
This commit is contained in:
parent
d0fc22a428
commit
1c71a7a1c4
@ -177,7 +177,7 @@ func (resp *Response) DecodeProp(values ...interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := resp.Err(); err != nil {
|
if err := resp.Err(); err != nil {
|
||||||
return err
|
return newPropError(name, err)
|
||||||
}
|
}
|
||||||
for _, propstat := range resp.Propstats {
|
for _, propstat := range resp.Propstats {
|
||||||
raw := propstat.Prop.Get(name)
|
raw := propstat.Prop.Get(name)
|
||||||
@ -185,16 +185,26 @@ func (resp *Response) DecodeProp(values ...interface{}) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := propstat.Status.Err(); err != nil {
|
if err := propstat.Status.Err(); err != nil {
|
||||||
return err
|
return newPropError(name, err)
|
||||||
}
|
}
|
||||||
return raw.Decode(v)
|
if err := raw.Decode(v); err != nil {
|
||||||
|
return newPropError(name, err)
|
||||||
}
|
}
|
||||||
return HTTPErrorf(http.StatusNotFound, "missing property %s", name)
|
return nil
|
||||||
|
}
|
||||||
|
return newPropError(name, &HTTPError{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
Err: fmt.Errorf("missing property"),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newPropError(name xml.Name, err error) error {
|
||||||
|
return fmt.Errorf("property <%v %v>: %w", name.Space, name.Local, err)
|
||||||
|
}
|
||||||
|
|
||||||
func (resp *Response) EncodeProp(code int, v interface{}) error {
|
func (resp *Response) EncodeProp(code int, v interface{}) error {
|
||||||
raw, err := EncodeRawXMLElement(v)
|
raw, err := EncodeRawXMLElement(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user