Skip to content

Commit 8320928

Browse files
committedJan 11, 2021
adding Err() to api response types
1 parent ed7bb3f commit 8320928

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎api_response.go

+11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ type APIResponseMetaContainer interface {
9898
type APIResponse interface {
9999
APIResponseMetaContainer
100100

101+
// Err must return the current state error, or nil if beginning state.
102+
Err() error
103+
101104
// Read returns the raw bytes from the HTTP response body. Once called
102105
//
103106
// This action is mutually exclusive with Hydrate.
@@ -153,6 +156,14 @@ func (b *RawAPIResponse) ResponseMeta() APIResponseMeta {
153156
return b.meta
154157
}
155158

159+
// Err returns the current state error, if there is one.
160+
func (b *RawAPIResponse) Err() error {
161+
b.mu.Lock()
162+
err := b.err
163+
b.mu.Unlock()
164+
return err
165+
}
166+
156167
// Read performs a read from the response body. Once this has been called, any Hydrate implementation will fail with an
157168
// error
158169
func (b *RawAPIResponse) Read(p []byte) (int, error) {

0 commit comments

Comments
 (0)
Please sign in to comment.