Skip to content

Commit 6acd44e

Browse files
committed
Fix return resp error
1 parent 5447e15 commit 6acd44e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

address.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func ReadAddress(ctx context.Context, addressId, uid, sid, sessionKey string) (*
7777

7878
var resp struct {
7979
Data *Address `json:"data"`
80-
Error Error `json:"error"`
80+
Error *Error `json:"error"`
8181
}
8282
err = json.Unmarshal(body, &resp)
8383
if err != nil {
@@ -137,13 +137,13 @@ func GetAddressesByAssetId(ctx context.Context, assetId, uid, sid, sessionKey st
137137

138138
var resp struct {
139139
Data []*Address `json:"data"`
140-
Error Error `json:"error"`
140+
Error *Error `json:"error"`
141141
}
142142
err = json.Unmarshal(body, &resp)
143143
if err != nil {
144144
return nil, BadDataError(ctx)
145145
}
146-
if resp.Error.Code > 0 {
146+
if resp.Error != nil {
147147
return nil, resp.Error
148148
}
149149
return resp.Data, nil

network.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ func ExternalAdddressCheck(ctx context.Context, asset, destination, tag string)
4848
if err != nil {
4949
return nil, BadDataError(ctx)
5050
}
51-
return resp.Data, resp.Error
51+
if resp.Error != nil {
52+
return nil, resp.Error
53+
}
54+
return resp.Data, nil
5255
}

transaction.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ func ExternalTranactions(ctx context.Context, asset, destination, tag string) ([
4040
}
4141
var resp struct {
4242
Data []*Transaction `json:"data"`
43-
Error Error `json:"error"`
43+
Error *Error `json:"error"`
4444
}
4545
err = json.Unmarshal(body, &resp)
4646
if err != nil {
4747
return nil, BadDataError(ctx)
4848
}
49-
return resp.Data, resp.Error
49+
if resp.Error != nil {
50+
return nil, resp.Error
51+
}
52+
return resp.Data, nil
5053
}

0 commit comments

Comments
 (0)