clean up reva ocdav webdav handler error handling
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 274
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 103
Description
Currently, the reva ocdav webdav handler followcs a mixed approach to error handling:
```
case MethodLock:
status, err = s.handleLock(w, r, ns)
...
case MethodMove:
s.handlePathMove(w, r, ns)
...
default:
w.WriteHeader(http.StatusNotFound)
}
if status != 0 { // 0 means the handler already sent the response
w.WriteHeader(status)
if status != http.StatusNoContent {
var b []byte
if b, err = errors.Marshal(status, err.Error(), ""); err == nil {
_, err = w.Write(b)
}
}
}
if err != nil {
appctx.GetLogger(r.Context()).Error().Err(err).Msg(err.Error())
}
```
All handlers should return a `status` and `err`, so the generic error handling can take place. In case the handler needs to handle a special case it can devactivate the generic handling by returning `status = 0`.
This will prevent and fix bugs where we don't render the xml body in an error case, eg:
- https://github.com/owncloud/ocis/issues/3882
- https://github.com/owncloud/ocis/issues/1945
- https://github.com/owncloud/ocis/issues/1293
It will make returning a special message easier, eg. for https://github.com/owncloud/ocis/issues/773
Contributor guide
Assessment
This issue has not been assessed yet.