Skip to content

Commit

Permalink
Do not discard errors from the gateway (#438)
Browse files Browse the repository at this point in the history
* Do not discard errors from the Gateway (Read and CreateIfNotExists)
  • Loading branch information
phliar committed Apr 22, 2020
1 parent 39776ea commit b92e906
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

## v3.4.23 (unreleased)
- no changes yet,
## v3.4.24 (unreleased)
- no changes yet.

## v3.4.23 (2020-04-22)
- Do not discard errors returned by the Gateway (for Read and CreateIfNotExists).

## v3.4.22 (2020-04-17)
- Add some String() methods to query-related objects
Expand Down
10 changes: 5 additions & 5 deletions connectors/yarpc/yarpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"context"
"encoding/json"
"fmt"
nethttp "net/http"
"net/url"
"strings"

Expand All @@ -44,8 +45,8 @@ import (

const (
_version = "version"
errCodeNotFound int32 = 404
errCodeAlreadyExists int32 = 409
errCodeNotFound int32 = nethttp.StatusNotFound
errCodeAlreadyExists int32 = nethttp.StatusConflict
errConnectionRefused string = "getsockopt: connection refused"
httpTransport string = "http"
tchannelTransport string = "tchannel"
Expand Down Expand Up @@ -216,10 +217,9 @@ func (c *Connector) CreateIfNotExists(ctx context.Context, ei *dosa.EntityInfo,
if err != nil {
if be, ok := err.(*dosarpc.BadRequestError); ok {
if be.ErrorCode != nil && *be.ErrorCode == errCodeAlreadyExists {
return errors.Wrap(&dosa.ErrAlreadyExists{}, "CreateIfNotExists failed")
return errors.Wrap(&dosa.ErrAlreadyExists{}, err.Error())
}
}

if !dosarpc.Dosa_CreateIfNotExists_Helper.IsException(err) {
return errors.Wrap(err, "CreateIfNotExists failed due to network issue")
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, keys map[stri
if err != nil {
if be, ok := err.(*dosarpc.BadRequestError); ok {
if be.ErrorCode != nil && *be.ErrorCode == errCodeNotFound {
return nil, errors.Wrap(&dosa.ErrNotFound{}, "Read failed: not found")
return nil, errors.Wrap(&dosa.ErrNotFound{}, err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
package dosa

// VERSION indicates the dosa client version
const VERSION = "3.4.22"
const VERSION = "3.4.23"

0 comments on commit b92e906

Please sign in to comment.