diff --git a/errors.go b/errors.go index d4b183c..662df19 100644 --- a/errors.go +++ b/errors.go @@ -30,7 +30,7 @@ const ( // Helper for constructing a ValidationError with a string error message func NewValidationError(errorText string, errorFlags uint32) *ValidationError { return &ValidationError{ - Inner: errors.New(errorText), + text: errorText, Errors: errorFlags, } } @@ -39,11 +39,16 @@ func NewValidationError(errorText string, errorFlags uint32) *ValidationError { type ValidationError struct { Inner error // stores the error returned by external dependencies, i.e.: KeyFunc Errors uint32 // bitfield. see ValidationError... constants + text string // errors that do not have a valid error just have text } // Validation error is an error type func (e ValidationError) Error() string { - if e.Inner == nil { + if e.Inner != nil { + return e.Inner.Error() + } else if e.text != "" { + return e.text + } else { return "token is invalid" } return e.Inner.Error()