fix: cleaned up errors code

- Parse errors are joined by "|" instead of ","
- Safer checking of generic errors

Signed-off-by: Calum Murray <cmurray@redhat.com>
This commit is contained in:
Calum Murray 2024-07-12 13:29:37 -04:00
parent a72f4a849e
commit 3ce6b2f1f0
No known key found for this signature in database
GPG Key ID: D9837BD1D90C1512
1 changed files with 3 additions and 2 deletions

View File

@ -19,6 +19,7 @@ const (
missingAttributeError
missingFunctionError
functionEvaluationError
dummyLastError // always add new error classes ABOVE this error
)
type cesqlError struct {
@ -62,7 +63,7 @@ func NewParseError(errs []error) error {
return cesqlError{
kind: parseError,
message: strings.Join(errorMessages, ","),
message: strings.Join(errorMessages, "|"),
}
}
@ -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
}