Uploaded image for project: 'Couchbase Go SDK'
  1. Couchbase Go SDK
  2. GOCBC-66

Utility method for KeyNotFound errors

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Minor
    • 1.0.3
    • 1.0.0
    • library
    • None

    Description

      The previous go library had a utility method for checking if an error is a KeyNotFound error [1].

      The new library lacks such a method, and one has to do some digging to figure out the solution:

      func keyNotFound(err error) bool {
      	if err == nil {
      		return false
      	} else if notFound, ok := err.(interface {
      		KeyNotFound() bool
      	}); !ok {
      		return false
      	} else {
      		return notFound.KeyNotFound()
      	}
      }
      

      It would be great to have a utility method for this idiom in the main pkg. Alternatively it would be great to see more information on error handling in the documentation.

      [1] https://godoc.org/github.com/couchbase/gomemcached#IsNotFound

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              brett19 Brett Lawson
              felixge Felix Geisendörfer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty