Returns the standard CouchDB error string for an HTTP error status. These are important for compatibility, as some REST APIs don't show numeric statuses, only these strings.
(status int)
| 199 | // These are important for compatibility, as some REST APIs don't show numeric statuses, |
| 200 | // only these strings. |
| 201 | func CouchHTTPErrorName(status int) string { |
| 202 | switch status { |
| 203 | case 400: |
| 204 | return "bad_request" |
| 205 | case 401: |
| 206 | return "unauthorized" |
| 207 | case 404: |
| 208 | return "not_found" |
| 209 | case 403: |
| 210 | return "forbidden" |
| 211 | case 406: |
| 212 | return "not_acceptable" |
| 213 | case 409: |
| 214 | return "conflict" |
| 215 | case 412: |
| 216 | return "file_exists" |
| 217 | case 415: |
| 218 | return "bad_content_type" |
| 219 | } |
| 220 | return fmt.Sprintf("%d", status) |
| 221 | } |
| 222 | |
| 223 | // IsDocNotFoundError returns true if an error is a doc-not-found error |
| 224 | func IsDocNotFoundError(err error) bool { |
no outgoing calls