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

fix: mark bad macros arguments count error as downstream #140

Merged
merged 1 commit into from
Nov 1, 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
3 changes: 3 additions & 0 deletions datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ func (ds *SQLDatasource) handleQuery(ctx context.Context, req backend.DataQuery,
// Apply supported macros to the query
q.RawSQL, err = Interpolate(ds.driver(), q)
if err != nil {
if errors.Is(err, sqlutil.ErrorBadArgumentCount) {
err = backend.DownstreamError(err)
}
return sqlutil.ErrorFrameFromQuery(q), fmt.Errorf("%s: %w", "Could not apply macros", err)
}

Expand Down
5 changes: 2 additions & 3 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ func DownstreamError(err error, override ...bool) error {
}

func ErrorSource(err error) backend.ErrorSource {
var se es.Error
if errors.As(err, &se) {
return se.Source()
if backend.IsDownstreamError(err) {
return backend.ErrorSourceDownstream
}
return backend.ErrorSourcePlugin
}