77
88 "github.com/grafana/grafana-plugin-sdk-go/backend/gtime"
99 "github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
10+ "github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
1011 "github.com/grafana/sqlds/v4"
1112 "github.com/pkg/errors"
1213 "github.com/viant/toolbox"
@@ -28,12 +29,12 @@ func parseTime(target, format string) string {
2829
2930func parseTimeGroup (query * sqlutil.Query , args []string ) (time.Duration , string , error ) {
3031 if len (args ) < 2 {
31- return 0 , "" , errors .WithMessagef (sqlds .ErrorBadArgumentCount , "macro $__timeGroup needs time column and interval" )
32+ return 0 , "" , errorsource . DownstreamError ( errors .WithMessagef (sqlds .ErrorBadArgumentCount , "macro $__timeGroup needs time column and interval" ), false )
3233 }
3334
3435 interval , err := gtime .ParseInterval (strings .Trim (args [1 ], `'` ))
3536 if err != nil {
36- return 0 , "" , fmt . Errorf ( "error parsing interval %v" , args [1 ])
37+ return 0 , "" , errors . WithMessagef ( err , "error parsing interval %v" , args [1 ])
3738 }
3839
3940 timeVar := args [0 ]
@@ -62,7 +63,7 @@ func macroUnixEpochGroup(query *sqlutil.Query, args []string) (string, error) {
6263
6364func macroParseTime (query * sqlutil.Query , args []string ) (string , error ) {
6465 if len (args ) < 1 {
65- return "" , errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected at least one argument" )
66+ return "" , errorsource . DownstreamError ( errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected at least one argument" ), false )
6667 }
6768
6869 var (
@@ -79,7 +80,7 @@ func macroParseTime(query *sqlutil.Query, args []string) (string, error) {
7980
8081func macroTimeFilter (query * sqlutil.Query , args []string ) (string , error ) {
8182 if len (args ) < 1 {
82- return "" , errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected at least one argument" )
83+ return "" , errorsource . DownstreamError ( errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected at least one argument" ), false )
8384 }
8485
8586 var (
@@ -99,7 +100,7 @@ func macroTimeFilter(query *sqlutil.Query, args []string) (string, error) {
99100
100101func macroUnixEpochFilter (query * sqlutil.Query , args []string ) (string , error ) {
101102 if len (args ) != 1 {
102- return "" , errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected one argument" )
103+ return "" , errorsource . DownstreamError ( errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected one argument" ), false )
103104 }
104105
105106 var (
@@ -140,7 +141,7 @@ func macroRawTimeTo(query *sqlutil.Query, args []string) (string, error) {
140141
141142func macroDateFilter (query * sqlutil.Query , args []string ) (string , error ) {
142143 if len (args ) != 1 {
143- return "" , errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected 1 argument, received %d" , len (args ))
144+ return "" , errorsource . DownstreamError ( errors .WithMessagef (sqlds .ErrorBadArgumentCount , "expected 1 argument, received %d" , len (args )), false )
144145 }
145146
146147 var (
0 commit comments