Skip to content

Commit

Permalink
GOCBC-193: Expose enhanced error messages.
Browse files Browse the repository at this point in the history
Motivation
----------
The server now supported sending detailed error messages
as part of a failed operation.

Changes
-------
Added ability to enable enhanced error messages through a
cluster level method.  Additionally we added the ability
to fetch the underlying error cause for an error.

Change-Id: I76034dc6a3ab05a12a554ae3a44f0056cc85e491
Reviewed-on: http://review.couchbase.org/82593
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
brett19 committed Aug 24, 2017
1 parent 6382451 commit 3f721d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ func Connect(connSpecStr string) (*Cluster, error) {
return cluster, nil
}

// EnhancedErrors returns the current enhanced error message state.
func (c *Cluster) EnhancedErrors() bool {
return c.agentConfig.UseEnhancedErrors
}

// SetEnhancedErrors sets the current enhanced error message state.
func (c *Cluster) SetEnhancedErrors(enabled bool) {
c.agentConfig.UseEnhancedErrors = enabled
}

// ConnectTimeout returns the maximum time to wait when attempting to connect to a bucket.
func (c *Cluster) ConnectTimeout() time.Duration {
return c.agentConfig.ConnectTimeout
Expand Down
5 changes: 5 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,8 @@ func IsKeyExistsError(err error) bool {
func IsKeyNotFoundError(err error) bool {
return gocbcore.IsErrorStatus(err, gocbcore.StatusKeyNotFound)
}

// ErrorCause returns the underlying error for an enhanced error.
func ErrorCause(err error) error {
return gocbcore.ErrorCause(err)
}

0 comments on commit 3f721d7

Please sign in to comment.