Skip to content

Commit 8683082

Browse files
committed
api: remove Future.Err()
The method causes an improper error handling because it returns an error only from a client side. Therefore, it is not enough to simply check the error to find out that the request was not completed. A user should check an error from `Future.Get()` or `Future.GetTyped()`. In addition, the user can find out whether there was an error without decoding the response body with `Future.GetResponse()`, see `ExampleErrorNo`.
1 parent 49571b6 commit 8683082

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
128128
- `Schema` field from the `Connection` struct (#7)
129129
- `OkCode` and `PushCode` constants (#237)
130130
- SSL support (#301)
131+
- `Future.Err()` method (#382)
131132

132133
### Fixed
133134

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ for an `ops` field. `*Operations` needs to be used instead.
352352
* `Future` constructors now accept `Request` as their argument.
353353
* Methods `AppendPush` and `SetResponse` accepts response `Header` and data
354354
as their arguments.
355+
* Method `Err` was removed because it was causing improper error handling. You
356+
You need to check an error from `Get`, `GetTyped` or `GetResponse` with
357+
an addition check of a value `Response.Header().Error`, see `ExampleErrorNo`.
355358

356359
#### Connector changes
357360

future.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,3 @@ func (fut *Future) WaitChan() <-chan struct{} {
266266
}
267267
return fut.done
268268
}
269-
270-
// Err returns error set on Future.
271-
// It waits for future to be set.
272-
// Note: it doesn't decode body, therefore decoding error are not set here.
273-
func (fut *Future) Err() error {
274-
fut.wait()
275-
return fut.err
276-
}

0 commit comments

Comments
 (0)