Commit Graph

6 Commits

Author SHA1 Message Date
Simon Ser
4e8c5effe3 Replace DAVError with HTTPError + Error
That way we can avoid having different ways of representing the
same error value.
2022-05-02 15:43:43 +02:00
Simon Ser
8738a105fc internal: add HTTPError.Unwrap
This allows callers to access the underlying error via errors.Unwrap.
2022-05-02 15:43:43 +02:00
Conrad Hoffmann
85d2b222bb Add error type representing DAV/XML errors
Backends will need some way to signal that a precondition error occurred
(and specifying which one) without causing the server to return a 500.
This commit adds an exported function to create a specific error for
this. The existing error handling routine is slightly adapted to handle
this error in such a way that it returns the desired result.

Usage would be something like:

```
return "", carddav.NewPreconditionError(carddav.PreconditionNoUIDConflict)
```

which triggers the following HTTP response:

```
HTTP/1.1 409 Conflict.
Content-Type: text/xml; charset=utf-8.
Date: Thu, 10 Mar 2022 10:28:56 GMT.
Content-Length: 141.
Connection: close.

<?xml version="1.0" encoding="UTF-8"?>
<error xmlns="DAV:"><no-uid-conflict
xmlns="urn:ietf:params:xml:ns:carddav"></no-uid-conflict></error>
```

This response gets correctly recognized by e.g. Evolution (though it's
handling is not great).

The added error type is generic enough to be used for other stuff also.
As it is not exported (internal package), new functions for creating
such errors would have to be added.
2022-03-10 16:48:11 +01:00
Simon Ser
25df841e2b
internal: move HTTPError to common file
This is used by both clients and servers now.
2020-05-13 18:24:29 +02:00
Simon Ser
d30d4d2932
internal: add helpers for the Overwrite header 2020-01-22 10:09:51 +01:00
Simon Ser
c0a91b0085
internal: move Depth to internal.go 2020-01-22 10:06:00 +01:00