forked from mirror/jwt
errors only have an exposed Inner property if the error was generated by another library
This commit is contained in:
parent
2ed748cd9c
commit
5fbf45924d
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue