Skip to content

Commit

Permalink
Make Keberos result codes available from errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenz committed May 14, 2021
1 parent 663478b commit b58f4ef
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions v8/krberror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const (

// Krberror is an error type for gokrb5
type Krberror struct {
RootCause string
EText []string
RootCause string
EText []string
innerError error
}

// Error function to implement the error interface.
Expand All @@ -35,6 +36,11 @@ func (e *Krberror) Add(et string, s string) {
e.EText = append([]string{fmt.Sprintf("%s: %s", et, s)}, e.EText...)
}

// Unwrap returns the inner error (if any)
func (e Krberror) Unwrap() error {
return e.innerError
}

// New creates a new instance of Krberror.
func New(et, s string) Krberror {
return Krberror{
Expand All @@ -49,7 +55,9 @@ func Errorf(err error, et, format string, a ...interface{}) Krberror {
e.Add(et, fmt.Sprintf(format, a...))
return e
}
return NewErrorf(et, format+": %s", append(a, err)...)
e := NewErrorf(et, format+": %s", append(a, err)...)
e.innerError = err
return e
}

// NewErrorf creates a new Krberror from a formatted string.
Expand Down

0 comments on commit b58f4ef

Please sign in to comment.