mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-30 12:06:26 +00:00
Add error returning for missing error output paths
Co-Authored-By: Captain ALM <captainalm@captainalm.com>
This commit is contained in:
parent
9094f8327e
commit
9dd12e301a
@ -1,6 +1,7 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -353,7 +354,7 @@ type Time time.Time
|
||||
func (t *Time) UnmarshalText(b []byte) error {
|
||||
tt, err := http.ParseTime(string(b))
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.New(err.Error() + " : time_data : " + base64.StdEncoding.EncodeToString(b))
|
||||
}
|
||||
*t = Time(tt)
|
||||
return nil
|
||||
|
@ -187,9 +187,8 @@ func NewPropFindResponse(path string, propfind *PropFind, props map[xml.Name]Pro
|
||||
|
||||
code := http.StatusOK
|
||||
if err != nil {
|
||||
// TODO: don't throw away error message here
|
||||
code = HTTPErrorFromError(err).Code
|
||||
val = emptyVal
|
||||
val = NewRawXMLElement(xmlName, []xml.Attr{{Name: xml.Name{Space: "ERR", Local: "Error"}, Value: err.Error()}}, nil)
|
||||
}
|
||||
|
||||
if err := resp.EncodeProp(code, val); err != nil {
|
||||
@ -210,8 +209,8 @@ func NewPropFindResponse(path string, propfind *PropFind, props map[xml.Name]Pro
|
||||
f, ok := props[xmlName]
|
||||
if ok {
|
||||
if v, err := f(&raw); err != nil {
|
||||
// TODO: don't throw away error message here
|
||||
code = HTTPErrorFromError(err).Code
|
||||
val = NewRawXMLElement(xmlName, []xml.Attr{{Name: xml.Name{Space: "ERR", Local: "Error"}, Value: err.Error()}}, nil)
|
||||
} else {
|
||||
code = http.StatusOK
|
||||
val = v
|
||||
|
Loading…
Reference in New Issue
Block a user