stackitem: rework error handling
Return good named errors everywhere, export appropriate constants, make errors.Is() work.
This commit is contained in:
parent
0de949b575
commit
5a9efcc654
5 changed files with 108 additions and 67 deletions
|
@ -1,6 +1,7 @@
|
|||
package stackitem
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -10,12 +11,13 @@ func TestSerializationMaxErr(t *testing.T) {
|
|||
base := make([]byte, MaxSize/2+1)
|
||||
item := Make(base)
|
||||
|
||||
arr := []Item{item, item.Dup()}
|
||||
// Pointer is unserializable, but we specifically want to catch ErrTooBig.
|
||||
arr := []Item{item, item.Dup(), NewPointer(0, []byte{})}
|
||||
aitem := Make(arr)
|
||||
|
||||
_, err := Serialize(item)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = Serialize(aitem)
|
||||
require.Error(t, err)
|
||||
require.True(t, errors.Is(err, ErrTooBig), err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue