fix HandshakeError

This commit is contained in:
Sergey Cherepanov 2023-05-22 18:00:30 +02:00 committed by Mikhail Iudin
parent d04e55bc9c
commit d8ed9f9307
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -19,22 +19,26 @@ const (
)
type HandshakeError struct {
err error
e handshakeproto.Error
}
func (he HandshakeError) Error() string {
if he.err != nil {
return he.err.Error()
}
return he.e.String()
}
var (
ErrUnexpectedPayload = HandshakeError{handshakeproto.Error_UnexpectedPayload}
ErrDeadlineExceeded = HandshakeError{handshakeproto.Error_DeadlineExceeded}
ErrInvalidCredentials = HandshakeError{handshakeproto.Error_InvalidCredentials}
ErrPeerDeclinedCredentials = errors.New("remote peer declined the credentials")
ErrSkipVerifyNotAllowed = HandshakeError{handshakeproto.Error_SkipVerifyNotAllowed}
ErrUnexpected = HandshakeError{handshakeproto.Error_Unexpected}
ErrUnexpectedPayload = HandshakeError{e: handshakeproto.Error_UnexpectedPayload}
ErrDeadlineExceeded = HandshakeError{e: handshakeproto.Error_DeadlineExceeded}
ErrInvalidCredentials = HandshakeError{e: handshakeproto.Error_InvalidCredentials}
ErrPeerDeclinedCredentials = HandshakeError{err: errors.New("remote peer declined the credentials")}
ErrSkipVerifyNotAllowed = HandshakeError{e: handshakeproto.Error_SkipVerifyNotAllowed}
ErrUnexpected = HandshakeError{e: handshakeproto.Error_Unexpected}
ErrIncompatibleVersion = HandshakeError{handshakeproto.Error_IncompatibleVersion}
ErrIncompatibleVersion = HandshakeError{e: handshakeproto.Error_IncompatibleVersion}
ErrGotNotAHandshakeMessage = errors.New("go not a handshake message")
)