Skip to content

Commit

Permalink
Merge pull request #917 from cloudflare/parser
Browse files Browse the repository at this point in the history
Remove dead code
  • Loading branch information
prymitive authored Mar 18, 2024
2 parents 4fcd703 + 01df83e commit 7e117c8
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions internal/parser/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,6 @@ import (
promParser "github.com/prometheus/prometheus/promql/parser"
)

type PromQLError struct {
node *PromQLNode
Err error
}

func (pqle PromQLError) Error() string {
return pqle.Err.Error()
}

func (pqle *PromQLError) Unwrap() error {
return pqle.Err
}

func (pqle PromQLError) Node() *PromQLNode {
return pqle.node
}

type PromQLExpr struct {
Value *YamlNode
SyntaxError error
Expand Down Expand Up @@ -111,18 +94,15 @@ func WalkUpParent[T promParser.Node](node *PromQLNode) (nodes []*PromQLNode) {

func DecodeExpr(expr string) (*PromQLNode, error) {
node, err := promParser.ParseExpr(expr)
if err != nil {
pqe := PromQLError{Err: err}
pqe.node = &PromQLNode{
Expr: node,
}
var perrs promParser.ParseErrors
if ok := errors.As(err, &perrs); ok {
for _, perr := range perrs {
pqe.Err = perr.Err
}
if err == nil {
return tree(node, nil), nil
}

var perrs promParser.ParseErrors
if ok := errors.As(err, &perrs); ok {
for _, perr := range perrs {
err = perr.Err
}
return nil, pqe
}
return tree(node, nil), nil
return nil, err
}

0 comments on commit 7e117c8

Please sign in to comment.