Skip to content

Commit

Permalink
Export more errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanahuckova committed Oct 7, 2024
1 parent 8657a8c commit bc34c88
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 2 deletions.
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

0 comments on commit bc34c88

Please sign in to comment.