Skip to content

Commit

Permalink
fix incorrect error info (#20661)
Browse files Browse the repository at this point in the history
fix incorrect error info

Approved by: @XuPeng-SH
  • Loading branch information
YANGGMM authored Dec 9, 2024
1 parent a0ec8ab commit e1c3f50
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
30 changes: 30 additions & 0 deletions pkg/container/bytejson/bytejosn_modifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,33 @@ func TestAppendBinaryString(t *testing.T) {
})
}
}

func Test_appendBinaryValElem(t *testing.T) {
tests := []struct {
name string
input any
wantType TpCode
wantErr bool
}{
{
name: "invalid type",
input: struct{}{},
wantType: 0,
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotBuf, err := appendBinaryValElem(make([]byte, 0), 0, 0, tt.input)

if tt.wantErr {
require.Error(t, err)
return
}

require.NoError(t, err)
require.NotEmpty(t, gotBuf)
})
}
}
3 changes: 1 addition & 2 deletions pkg/container/bytejson/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/util"
"github.com/pingcap/errors"
)

func ParseFromString(s string) (ret ByteJson, err error) {
Expand Down Expand Up @@ -673,7 +672,7 @@ func appendBinaryValElem(buf []byte, docOff, valEntryOff int, val any) ([]byte,
elemDocOff := len(buf)
typeCode, buf, err = appendBinaryJSON(buf, val)
if err != nil {
return nil, errors.Trace(err)
return nil, moerr.NewInvalidArgNoCtx("invalid json value", val)
}
if typeCode == TpCodeLiteral {
litCode := buf[elemDocOff]
Expand Down

0 comments on commit e1c3f50

Please sign in to comment.