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

Improve and export errors in packages #10

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/go/framesql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @grafana/infinity-framesql

## 1.0.2

- ⚙️ **Chore**: improved error messages

## 1.0.1

- ⚙️ **Chore**: improved error messages
Expand Down
1 change: 1 addition & 0 deletions lib/go/framesql/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import "errors"

var (
ErrEmptySummarizeExpression = errors.New("empty/invalid summarize expression")
ErrExpressionNotFoundInFields = errors.New("expression not found in fields")
)
12 changes: 12 additions & 0 deletions lib/go/framesql/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func EvaluateInFrame(expression string, input *data.Frame) (any, error) {
}
}
result, err := parsedExpression.Evaluate(parameters)
if err != nil {
if checkIfExpressionFoundInFields(err) {
return result, errors.Join(err, ErrExpressionNotFoundInFields)
}
}
return result, err
}

Expand Down Expand Up @@ -206,3 +211,10 @@ func toFloat64p(input any) (*float64, bool) {
}
return nil, false
}

func checkIfExpressionFoundInFields(err error) bool {
r := regexp.MustCompile(`No parameter '(.+)' found\.`)
// Check if the message matches the pattern
matches := r.FindStringSubmatch(err.Error())
return len(matches) > 0
}
2 changes: 1 addition & 1 deletion lib/go/framesql/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@grafana/infinity-framesql",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"tidy": "go mod tidy",
"test:backend": "go test -v ./..."
Expand Down
4 changes: 4 additions & 0 deletions lib/go/transformations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @grafana/infinity-transformations

## 1.0.2

- ⚙️ **Chore**: improved error messages

## 1.0.1

- ⚙️ **Chore**: improved error messages
Expand Down
1 change: 1 addition & 0 deletions lib/go/transformations/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var (
ErrSummarizeByFieldNotFound = errors.New("summarize by field not found. Not applying summarize")
ErrNotUniqueFieldNames = errors.New("field names are not unique. Not applying filter")
ErrEvaluatingFilterExpression = errors.New("error evaluating filter expression")
ErrInvalidToken = errors.New("invalid token")

ErrMergeTransformationNoFrameSupplied = errors.New("no frames supplied for merge frame transformation")
ErrMergeTransformationDifferentFields = errors.New("unable to merge fields due to different fields")
Expand Down
2 changes: 1 addition & 1 deletion lib/go/transformations/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@grafana/infinity-transformations",
"private": true,
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"tidy": "go mod tidy",
"test:backend": "go test -v ./..."
Expand Down
Loading