From 3891179da9dd6a5d77bc13c19e607d364e48b0e7 Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Fri, 24 May 2024 13:42:59 +0800 Subject: [PATCH] not panic --- ast/search.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ast/search.go b/ast/search.go index 7f0789ffd..e75d8b8bb 100644 --- a/ast/search.go +++ b/ast/search.go @@ -17,8 +17,10 @@ package ast import ( - `github.com/bytedance/sonic/internal/rt` - `github.com/bytedance/sonic/internal/native/types` + "errors" + + "github.com/bytedance/sonic/internal/native/types" + "github.com/bytedance/sonic/internal/rt" ) type Searcher struct { @@ -59,7 +61,7 @@ func (self *Searcher) getByPath(copystring bool, path ...interface{}) (Node, err return Node{}, ErrNotExist } if err == types.ERR_UNSUPPORT_TYPE { - panic("path must be either int(>=0) or string") + return Node{}, errors.New("path must be either int(>=0) or string") } return Node{}, self.parser.syntaxError(err) }