The bagit-gython Validate() method returns a Go error for both validation errors (i.e. the program worked correctly but the bag is not valid) and application errors (e.g. the program failed unexpectedly) and it's difficult for the caller differentiate between the two types of errors.
The bagit-gython
Validate()
method returns a Go error for both validation errors (i.e. the program worked correctly but the bag is not valid) and application errors (e.g. the program failed unexpectedly) and it's difficult for the caller differentiate between the two types of errors.Describe the solution you'd like
Return a custom validation error type for validation errors so the caller can check the error type to distinguish validation errors from application errors. See https://pkg.go.dev/github.com/go-ozzo/ozzo-validation/v4#Errors and https://pkg.go.dev/github.com/go-playground/validator/v10#ValidationErrors as examples.
Describe alternatives you've considered
Return validation errors as a separate value from the error value, e.g.
A downside of this solution is that it would be inconsistent with the
Validate()
interface of popular Go validation packages like https://github.com/go-playground/validator and https://github.com/go-ozzo/ozzo-validation that only return a single error value.