Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up reva ocdav webdav handler error handling #5009

Open
butonic opened this issue Nov 8, 2022 · 0 comments
Open

clean up reva ocdav webdav handler error handling #5009

butonic opened this issue Nov 8, 2022 · 0 comments

Comments

@butonic
Copy link
Member

butonic commented Nov 8, 2022

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:

It will make returning a special message easier, eg. for #773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Qualification
Development

No branches or pull requests

1 participant