Files
tasks/common/persistence/visibility/store/query/errors.go
Stephan BehnkeandGitHub c9e360a3fb go fix (#9337)
## What changed?

Integrate Go 1.26's new `go fix` into workflow.

NOTE that the changes caused our linter to fire; a [separate
commit](https://github.com/temporalio/temporal/pull/9337/commits/1b23f787aef370098b35829c4d17dcc06230b4c1)
addresses those.

## Why?

Ensure Go code is standardized/modernized.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [x] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
2026-02-18 09:12:19 -08:00

58 lines
1.2 KiB
Go

package query
import (
"errors"
"fmt"
"strings"
enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/api/serviceerror"
)
type (
ConverterError struct {
message string
}
)
var (
MalformedSqlQueryErrMessage = "malformed SQL query"
NotSupportedErrMessage = "operation is not supported"
InvalidExpressionErrMessage = "invalid expression"
)
func NewConverterError(format string, a ...any) error {
message := fmt.Sprintf(format, a...)
return &ConverterError{message: message}
}
func (c *ConverterError) Error() string {
return c.message
}
func (c *ConverterError) ToInvalidArgument() error {
return serviceerror.NewInvalidArgumentf("invalid query: %v", c)
}
func NewOperatorNotSupportedError(
saName string,
saType enumspb.IndexedValueType,
operator string,
) error {
return NewConverterError(
"%s: operator '%s' not supported for %s type search attribute '%s'",
NotSupportedErrMessage,
strings.ToUpper(operator),
saType.String(),
saName,
)
}
func wrapConverterError(message string, err error) error {
var converterErr *ConverterError
if errors.As(err, &converterErr) {
return NewConverterError("%s: %v", message, converterErr)
}
return err
}