MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / CouchHTTPErrorName

Function CouchHTTPErrorName

base/error.go:201–221  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

199// These are important for compatibility, as some REST APIs don't show numeric statuses,
200// only these strings.
201func 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
224func IsDocNotFoundError(err error) bool {

Callers 4

handleAllDocsMethod · 0.92
handleBulkGetMethod · 0.92
handleBulkDocsMethod · 0.92
TestCouchHTTPErrorNameFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCouchHTTPErrorNameFunction · 0.68