Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Keberos result codes available from errors #440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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