Skip to content

Commit

Permalink
fix: cleaned up errors code
Browse files Browse the repository at this point in the history
- Parse errors are joined by "|" instead of ","
- Safer checking of generic errors

Signed-off-by: Calum Murray <cmurray@redhat.com>
  • Loading branch information
Cali0707 committed Jul 12, 2024
1 parent a72f4a8 commit 3ce6b2f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sql/v2/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
missingAttributeError
missingFunctionError
functionEvaluationError
dummyLastError // always add new error classes ABOVE this error
)

type cesqlError struct {
Expand Down Expand Up @@ -62,7 +63,7 @@ func NewParseError(errs []error) error {

return cesqlError{
kind: parseError,
message: strings.Join(errorMessages, ","),
message: strings.Join(errorMessages, "|"),
}
}

Expand Down Expand Up @@ -145,7 +146,7 @@ func NewFunctionEvaluationError(err error) error {

func IsGenericError(err error) bool {
if cesqlErr, ok := err.(cesqlError); ok {
return cesqlErr.kind < parseError || cesqlErr.kind > functionEvaluationError
return cesqlErr.kind < 0 || cesqlErr.kind >= dummyLastError
}
return false
}

0 comments on commit 3ce6b2f

Please sign in to comment.