@cryptotaxi247 / kubo / commits / 5a8e2b77c

chore: rename abyfyIpldErrNotFound to parseIPLDErrNotFound

This commit was moved from ipfs/go-ipfs-http-client@7aa002992970058e37bb82f9837a442227562d33

Jorropo committed Mar 30, 2022 at 04:32 UTC 5a8e2b77c0e4361a0dd6e57a7f4129adba2f4d8a
3 files changed +13 -13
client/httpapi/block.go
+3 -3
@@ -66,7 +66,7 @@ func (api *BlockAPI) Get(ctx context.Context, p path.Path) (io.Reader, error) {
66 return nil, err
67 }
68 if resp.Error != nil {
69 - return nil, abyfyIpldNotFoundFallbackToError(resp.Error)
69 + return nil, parseIPLDNotFoundWithFallbackToError(resp.Error)
70 }
71
72 //TODO: make get return ReadCloser to avoid copying
@@ -98,14 +98,14 @@ func (api *BlockAPI) Rm(ctx context.Context, p path.Path, opts ...caopts.BlockRm
98 return err
99 }
100
101 - return abyfyIpldNotFoundFallbackToMSG(removedBlock.Error)
101 + return parseIPLDNotFoundWithFallbackToMSG(removedBlock.Error)
102 }
103
104 func (api *BlockAPI) Stat(ctx context.Context, p path.Path) (iface.BlockStat, error) {
105 var out blockStat
106 err := api.core().Request("block/stat", p.String()).Exec(ctx, &out)
107 if err != nil {
108 - return nil, abyfyIpldNotFoundFallbackToError(err)
108 + return nil, parseIPLDNotFoundWithFallbackToError(err)
109 }
110 out.cid, err = cid.Parse(out.Key)
111 if err != nil {
client/httpapi/errors.go renamed
+5 -5
@@ -27,8 +27,8 @@ func (e prePostWrappedNotFoundError) Unwrap() error {
27 return e.wrapped
28 }
29
30 -func abyfyIpldNotFoundFallbackToMSG(msg string) error {
31 - err, handled := abyfyIpldNotFound(msg)
30 +func parseIPLDNotFoundWithFallbackToMSG(msg string) error {
31 + err, handled := parseIPLDNotFound(msg)
32 if handled {
33 return err
34 }
@@ -36,8 +36,8 @@ func abyfyIpldNotFoundFallbackToMSG(msg string) error {
36 return errors.New(msg)
37 }
38
39 -func abyfyIpldNotFoundFallbackToError(msg error) error {
40 - err, handled := abyfyIpldNotFound(msg.Error())
39 +func parseIPLDNotFoundWithFallbackToError(msg error) error {
40 + err, handled := parseIPLDNotFound(msg.Error())
41 if handled {
42 return err
43 }
@@ -47,7 +47,7 @@ func abyfyIpldNotFoundFallbackToError(msg error) error {
47
48 // This file handle parsing and returning the correct ABI based errors from error messages
49 //lint:ignore ST1008 this function is not using the error as a mean to return failure but it massages it to return the correct type
50 -func abyfyIpldNotFound(msg string) (error, bool) {
50 +func parseIPLDNotFound(msg string) (error, bool) {
51 if msg == "" {
52 return nil, true // Fast path
53 }
client/httpapi/errors_test.go renamed
+5 -5
@@ -12,10 +12,10 @@ import (
12
13 var randomSha256MH = mh.Multihash{0x12, 0x20, 0x88, 0x82, 0x73, 0x37, 0x7c, 0xc1, 0xc9, 0x96, 0xad, 0xee, 0xd, 0x26, 0x84, 0x2, 0xc9, 0xc9, 0x5c, 0xf9, 0x5c, 0x4d, 0x9b, 0xc3, 0x3f, 0xfb, 0x4a, 0xd8, 0xaf, 0x28, 0x6b, 0xca, 0x1a, 0xf2}
14
15 -func doAbyfyIpldNotFoundTest(t *testing.T, original error) {
15 +func doParseIpldNotFoundTest(t *testing.T, original error) {
16 originalMsg := original.Error()
17
18 - rebuilt := abyfyIpldNotFoundFallbackToMSG(originalMsg)
18 + rebuilt := parseIPLDNotFoundWithFallbackToMSG(originalMsg)
19
20 rebuiltMsg := rebuilt.Error()
21
@@ -30,8 +30,8 @@ func doAbyfyIpldNotFoundTest(t *testing.T, original error) {
30 }
31 }
32
33 -func TestAbyfyIpldNotFound(t *testing.T) {
34 - if err := abyfyIpldNotFoundFallbackToMSG(""); err != nil {
33 +func TestParseIPLDNotFound(t *testing.T) {
34 + if err := parseIPLDNotFoundWithFallbackToMSG(""); err != nil {
35 t.Errorf("expected empty string to give no error; got %T %q", err, err.Error())
36 }
37
@@ -54,7 +54,7 @@ func TestAbyfyIpldNotFound(t *testing.T) {
54 err = fmt.Errorf(wrap, err)
55 }
56
57 - doAbyfyIpldNotFoundTest(t, err)
57 + doParseIpldNotFoundTest(t, err)
58 }
59 }
60 }