package krberror
import (
"fmt"
"strings"
)
const (
separator = " < "
EncodingError = "Encoding_Error"
NetworkingError = "Networking_Error"
DecryptingError = "Decrypting_Error"
EncryptingError = "Encrypting_Error"
ChksumError = "Checksum_Error"
KRBMsgError = "KRBMessage_Handling_Error"
ConfigError = "Configuration_Error"
KDCError = "KDC_Error"
)
type Krberror struct {
RootCause string
EText []string
}
func (e Krberror ) Error () string {
return fmt .Sprintf ("[Root cause: %s] " , e .RootCause ) + strings .Join (e .EText , separator )
}
func (e *Krberror ) Add (et string , s string ) {
e .EText = append ([]string {fmt .Sprintf ("%s: %s" , et , s )}, e .EText ...)
}
func New (et , s string ) Krberror {
return Krberror {
RootCause : et ,
EText : []string {s },
}
}
func Errorf (err error , et , format string , a ...interface {}) Krberror {
if e , ok := err .(Krberror ); ok {
e .Add (et , fmt .Sprintf (format , a ...))
return e
}
return NewErrorf (et , format +": %s" , append (a , err )...)
}
func NewErrorf (et , format string , a ...interface {}) Krberror {
var s string
if len (a ) > 0 {
s = fmt .Sprintf ("%s: %s" , et , fmt .Sprintf (format , a ...))
} else {
s = fmt .Sprintf ("%s: %s" , et , format )
}
return Krberror {
RootCause : et ,
EText : []string {s },
}
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .