Skip to content

Commit

Permalink
GOCBC-907: Add extra search error fields
Browse files Browse the repository at this point in the history
Motivation
----------
At the moment when we get an unknown search error we return an error
with "search error | {...}" the information contained doesn't actually
cover why the search failed. This detail is already exposed from
gocbcore we just aren't exposing it in gocb.

Changes
-------
Update error wrapping to handle search errors.
Add ErrorText and IndexName fields to SearchError.

Change-Id: Id458cdc56e767aa655087ebd78001883b04fd465
Reviewed-on: http://review.couchbase.org/c/gocb/+/129529
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck committed Jun 2, 2020
1 parent 6aeaab9 commit 778ae1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions error_search.go
Expand Up @@ -8,6 +8,8 @@ type SearchError struct {
Endpoint string `json:"endpoint,omitempty"`
RetryReasons []RetryReason `json:"retry_reasons,omitempty"`
RetryAttempts uint32 `json:"retry_attempts,omitempty"`
ErrorText string `json:"error_text"`
IndexName string `json:"index_name,omitempty"`
}

// Error returns the string representation of this error.
Expand Down
11 changes: 11 additions & 0 deletions error_wrapping.go
Expand Up @@ -68,6 +68,17 @@ func maybeEnhanceCoreErr(err error) error {
RetryAttempts: analyticsErr.RetryAttempts,
}
}
if searchErr, ok := err.(*gocbcore.SearchError); ok {
return &SearchError{
InnerError: searchErr.InnerError,
Query: searchErr.Query,
Endpoint: searchErr.Endpoint,
RetryReasons: translateCoreRetryReasons(searchErr.RetryReasons),
RetryAttempts: searchErr.RetryAttempts,
ErrorText: searchErr.ErrorText,
IndexName: searchErr.IndexName,
}
}
if httpErr, ok := err.(*gocbcore.HTTPError); ok {
return &HTTPError{
InnerError: httpErr.InnerError,
Expand Down

0 comments on commit 778ae1d

Please sign in to comment.