Skip to content

Commit

Permalink
Better error handling between SDK and API. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
drohit-cb authored Dec 2, 2024
1 parent 0e54da1 commit 88b4973
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## Unreleased

## [0.0.15] - 2024-12-02

### Added

- Add `WithIntegratorContractAddress` to allow for setting an explicit integrator contract address for Shared ETH staking.

### Fixed

- Better error handling between the SDK and the API.

## [0.0.14] - 2024-11-26

### Added
Expand All @@ -21,7 +31,7 @@
- Added constants for supported network names
- Added `IsFailedState` and `IsCompleteState` methods to `StakingOperation` to check if the operation is in a failed or complete state

### Changes
### Changed

- Exposed `IsTerminalState` method on `StakingOperation` to check if the operation is in a terminal state.

Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
"Correlation-Context",
fmt.Sprintf(
"%s,%s",
fmt.Sprintf("%s=%s", "sdk_version", "0.0.14"),
fmt.Sprintf("%s=%s", "sdk_version", "0.0.15"),
fmt.Sprintf("%s=%s", "sdk_language", "go"),
),
)
Expand Down
5 changes: 5 additions & 0 deletions pkg/coinbase/staking_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ func WithStakingOperationMode(mode string) StakingOperationOption {
return WithStakingOperationOption("mode", mode)
}

// WithIntegratorContractAddress allows for the setting of the integrator contract address for Shared ETH staking.
func WithIntegratorContractAddress(integratorContractAddress string) StakingOperationOption {
return WithStakingOperationOption("integrator_contract_address", integratorContractAddress)
}

// WithStakingOperationOption allows for the passing of custom options
// to the staking operation, like `mode` or `withdrawal_address`.
func WithStakingOperationOption(optionKey, optionValue string) StakingOperationOption {
Expand Down
4 changes: 2 additions & 2 deletions pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func MapToUserFacing(err error, resp *http.Response) error {
var openAPIError *client.GenericOpenAPIError
if errors.As(err, &openAPIError) {
var clientError client.Error
if err := clientError.UnmarshalJSON(openAPIError.Body()); err != nil {
if unmarshalErr := clientError.UnmarshalJSON(openAPIError.Body()); unmarshalErr != nil {
return &APIError{
Code: "unknown",
Message: err.Error(),
Message: err.Error(), // relay back the original error message as is.
}
}

Expand Down

0 comments on commit 88b4973

Please sign in to comment.