From 5ad25712a5dd8f8b8d8c005edbcc089973ebe57a Mon Sep 17 00:00:00 2001 From: Oleg Jukovec Date: Thu, 8 Feb 2024 19:04:08 +0300 Subject: [PATCH] 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`. --- CHANGELOG.md | 1 + README.md | 3 +++ future.go | 8 -------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c71a63146..4e7819d0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release. - `Schema` field from the `Connection` struct (#7) - `OkCode` and `PushCode` constants (#237) - SSL support (#301) +- `Future.Err()` method (#382) ### Fixed diff --git a/README.md b/README.md index 85ca776a1..d11c6a0e8 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,9 @@ for an `ops` field. `*Operations` needs to be used instead. * `Future` constructors now accept `Request` as their argument. * Methods `AppendPush` and `SetResponse` accepts response `Header` and data as their arguments. +* Method `Err` removed because it provokes an invalid error checking. You need + to check an error from `Get`, `GetTyped` or `GetResponse` with an addition + check a value of `Response.Header().Error`. #### Connector changes diff --git a/future.go b/future.go index 1b9f2ed14..64e2805f1 100644 --- a/future.go +++ b/future.go @@ -266,11 +266,3 @@ func (fut *Future) WaitChan() <-chan struct{} { } return fut.done } - -// Err returns error set on Future. -// It waits for future to be set. -// Note: it doesn't decode body, therefore decoding error are not set here. -func (fut *Future) Err() error { - fut.wait() - return fut.err -}