summaryrefslogtreecommitdiff
path: root/vendor/github.com/bytedance/sonic/ast/error.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-11-27 13:15:03 +0000
committerLibravatar GitHub <noreply@github.com>2023-11-27 13:15:03 +0000
commit66b77acb1c8b86f0be3836ccaf31683c0bfa317a (patch)
tree9a255a8ea8ef97229b6d75d17de45bdac1755be9 /vendor/github.com/bytedance/sonic/ast/error.go
parent[bugfix] Add Actor to outgoing poll vote Create; other fixes (#2384) (diff)
downloadgotosocial-66b77acb1c8b86f0be3836ccaf31683c0bfa317a.tar.xz
[chore]: Bump github.com/gin-contrib/cors from 1.4.0 to 1.5.0 (#2388)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/bytedance/sonic/ast/error.go')
-rw-r--r--vendor/github.com/bytedance/sonic/ast/error.go44
1 files changed, 38 insertions, 6 deletions
diff --git a/vendor/github.com/bytedance/sonic/ast/error.go b/vendor/github.com/bytedance/sonic/ast/error.go
index f4c441ae6..00a04468e 100644
--- a/vendor/github.com/bytedance/sonic/ast/error.go
+++ b/vendor/github.com/bytedance/sonic/ast/error.go
@@ -8,23 +8,55 @@ import (
`github.com/bytedance/sonic/internal/native/types`
)
-func (self *Parser) syntaxError(err types.ParsingError) SyntaxError {
- return SyntaxError{
- Pos : self.p,
- Src : self.s,
- Code: err,
+
+func newError(err types.ParsingError, msg string) *Node {
+ return &Node{
+ t: V_ERROR,
+ l: uint(err),
+ p: unsafe.Pointer(&msg),
}
}
+// Error returns error message if the node is invalid
+func (self Node) Error() string {
+ if self.t != V_ERROR {
+ return ""
+ } else {
+ return *(*string)(self.p)
+ }
+}
+
func newSyntaxError(err SyntaxError) *Node {
msg := err.Description()
return &Node{
t: V_ERROR,
- v: int64(err.Code),
+ l: uint(err.Code),
p: unsafe.Pointer(&msg),
}
}
+func (self *Parser) syntaxError(err types.ParsingError) SyntaxError {
+ return SyntaxError{
+ Pos : self.p,
+ Src : self.s,
+ Code: err,
+ }
+}
+
+func unwrapError(err error) *Node {
+ if se, ok := err.(*Node); ok {
+ return se
+ }else if sse, ok := err.(Node); ok {
+ return &sse
+ } else {
+ msg := err.Error()
+ return &Node{
+ t: V_ERROR,
+ p: unsafe.Pointer(&msg),
+ }
+ }
+}
+
type SyntaxError struct {
Pos int
Src string