Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code #917

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading