@@ -239,12 +239,12 @@ func (dbclient *couchDatabase) createDatabaseIfNotExist() error {
239239
240240 dbInfo , couchDBReturn , err := dbclient .getDatabaseInfo ()
241241 if err != nil {
242- if couchDBReturn == nil || couchDBReturn .StatusCode != 404 {
242+ if couchDBReturn == nil || couchDBReturn .StatusCode != http . StatusNotFound {
243243 return err
244244 }
245245 }
246246
247- if dbInfo == nil || couchDBReturn .StatusCode == 404 {
247+ if dbInfo == nil || couchDBReturn .StatusCode == http . StatusNotFound {
248248 couchdbLogger .Debugf ("[%s] Database does not exist." , dbclient .dbName )
249249
250250 connectURL , err := url .Parse (dbclient .couchInstance .url ())
@@ -265,7 +265,7 @@ func (dbclient *couchDatabase) createDatabaseIfNotExist() error {
265265 // returned due to a timeout or race condition.
266266 // Do a final check to see if the database really got created.
267267 dbInfo , couchDBReturn , dbInfoErr := dbclient .getDatabaseInfo ()
268- if dbInfoErr != nil || dbInfo == nil || couchDBReturn .StatusCode == 404 {
268+ if dbInfoErr != nil || dbInfo == nil || couchDBReturn .StatusCode == http . StatusNotFound {
269269 return err
270270 }
271271 }
@@ -494,7 +494,7 @@ func (dbclient *couchDatabase) dropDatabase() error {
494494
495495 resp , couchdbReturn , err := dbclient .handleRequest (http .MethodDelete , "DropDatabase" , connectURL , nil , "" , "" , maxRetries , true , nil )
496496 defer closeResponseBody (resp )
497- if couchdbReturn != nil && couchdbReturn .StatusCode == 404 {
497+ if couchdbReturn != nil && couchdbReturn .StatusCode == http . StatusNotFound {
498498 couchdbLogger .Debugf ("[%s] Exiting DropDatabase(), database does not exist" , dbclient .dbName )
499499 return nil
500500 }
@@ -721,7 +721,7 @@ func (dbclient *couchDatabase) readDoc(id string) (*couchDoc, string, error) {
721721
722722 resp , couchDBReturn , err := dbclient .handleRequest (http .MethodGet , "ReadDoc" , readURL , nil , "" , "" , maxRetries , true , & query , id )
723723 if err != nil {
724- if couchDBReturn != nil && couchDBReturn .StatusCode == 404 {
724+ if couchDBReturn != nil && couchDBReturn .StatusCode == http . StatusNotFound {
725725 couchdbLogger .Debugf ("[%s] Document not found (404), returning nil value instead of 404 error" , dbclient .dbName )
726726 // non-existent document should return nil value instead of a 404 error
727727 // for details see https://github.com/hyperledger-archives/fabric/issues/936
@@ -972,7 +972,7 @@ func (dbclient *couchDatabase) deleteDoc(id, rev string) error {
972972 resp , couchDBReturn , err := dbclient .handleRequestWithRevisionRetry (id , http .MethodDelete , dbName , "DeleteDoc" ,
973973 deleteURL , nil , "" , "" , maxRetries , true , nil )
974974 if err != nil {
975- if couchDBReturn != nil && couchDBReturn .StatusCode == 404 {
975+ if couchDBReturn != nil && couchDBReturn .StatusCode == http . StatusNotFound {
976976 couchdbLogger .Debugf ("[%s] Document not found (404), returning nil value instead of 404 error" , dbclient .dbName )
977977 // non-existent document should return nil value instead of a 404 error
978978 // for details see https://github.com/hyperledger-archives/fabric/issues/936
@@ -1525,7 +1525,7 @@ func (dbclient *couchDatabase) handleRequestWithRevisionRetry(id, method, dbName
15251525
15261526 // If there was a 409 conflict error during the save/delete, log it and retry it.
15271527 // Otherwise, break out of the retry loop
1528- if couchDBReturn != nil && couchDBReturn .StatusCode == 409 {
1528+ if couchDBReturn != nil && couchDBReturn .StatusCode == http . StatusConflict {
15291529 couchdbLogger .Warningf ("CouchDB document revision conflict detected, retrying. Attempt:%v" , attempts + 1 )
15301530 revisionConflictDetected = true
15311531 } else {
@@ -1641,9 +1641,9 @@ func (couchInstance *couchInstance) handleRequest(ctx context.Context, method, d
16411641 }
16421642
16431643 // if there is no golang http error and no CouchDB 500 error, then drop out of the retry
1644- if errResp == nil && resp != nil && resp .StatusCode < 500 {
1644+ if errResp == nil && resp != nil && resp .StatusCode < http . StatusInternalServerError {
16451645 // if this is an error, then populate the couchDBReturn
1646- if resp .StatusCode >= 400 {
1646+ if resp .StatusCode >= http . StatusBadRequest {
16471647 // Read the response body and close it for next attempt
16481648 jsonError , err := io .ReadAll (resp .Body )
16491649 if err != nil {
@@ -1727,7 +1727,7 @@ func (couchInstance *couchInstance) handleRequest(ctx context.Context, method, d
17271727 // check to see if the status code from couchdb is 400 or higher
17281728 // response codes 4XX and 500 will be treated as errors -
17291729 // golang error will be created from the couchDBReturn contents and both will be returned
1730- if resp .StatusCode >= 400 {
1730+ if resp .StatusCode >= http . StatusBadRequest {
17311731
17321732 // if the status code is 400 or greater, log and return an error
17331733 couchdbLogger .Debugf ("Error handling CouchDB request. Error:%s, Status Code:%v, Reason:%s" ,
0 commit comments