2016-06-27 01:56:23 +00:00
|
|
|
package utils
|
|
|
|
|
2017-05-02 23:33:51 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Error captures various common ricochet errors
|
|
|
|
type Error string
|
|
|
|
|
|
|
|
func (e Error) Error() string { return string(e) }
|
|
|
|
|
|
|
|
// Defining Versions
|
|
|
|
const (
|
|
|
|
VersionNegotiationError = Error("VersionNegotiationError")
|
|
|
|
VersionNegotiationFailed = Error("VersionNegotiationFailed")
|
|
|
|
|
|
|
|
RicochetConnectionClosed = Error("RicochetConnectionClosed")
|
|
|
|
RicochetProtocolError = Error("RicochetProtocolError")
|
|
|
|
|
|
|
|
UnknownChannelTypeError = Error("UnknownChannelTypeError")
|
|
|
|
UnauthorizedChannelTypeError = Error("UnauthorizedChannelTypeError")
|
|
|
|
|
2017-07-04 18:29:11 +00:00
|
|
|
// Timeout Errors
|
2017-05-02 23:33:51 +00:00
|
|
|
ActionTimedOutError = Error("ActionTimedOutError")
|
2017-07-04 18:29:11 +00:00
|
|
|
PeerTimedOutError = Error("PeerTimedOutError")
|
2017-05-02 23:33:51 +00:00
|
|
|
|
2017-07-04 18:29:11 +00:00
|
|
|
// Authentication Errors
|
|
|
|
ClientFailedToAuthenticateError = Error("ClientFailedToAuthenticateError")
|
|
|
|
ServerRejectedClientConnectionError = Error("ServerRejectedClientConnectionError")
|
2017-06-27 17:39:33 +00:00
|
|
|
|
2017-07-04 18:29:11 +00:00
|
|
|
UnauthorizedActionError = Error("UnauthorizedActionError")
|
|
|
|
ChannelClosedByPeerError = Error("ChannelClosedByPeerError")
|
2017-06-27 17:39:33 +00:00
|
|
|
|
2017-07-04 18:29:11 +00:00
|
|
|
// Channel Management Errors
|
|
|
|
ServerAttemptedToOpenEvenNumberedChannelError = Error("ServerAttemptedToOpenEvenNumberedChannelError")
|
|
|
|
ClientAttemptedToOpenOddNumberedChannelError = Error("ClientAttemptedToOpenOddNumberedChannelError")
|
|
|
|
ChannelIDIsAlreadyInUseError = Error("ChannelIDIsAlreadyInUseError")
|
|
|
|
AttemptToOpenMoreThanOneSingletonChannelError = Error("AttemptToOpenMoreThanOneSingletonChannelError")
|
|
|
|
|
|
|
|
// Library Use Errors
|
|
|
|
PrivateKeyNotSetError = Error("ClientFailedToAuthenticateError")
|
2017-05-02 23:33:51 +00:00
|
|
|
)
|
2016-06-27 01:56:23 +00:00
|
|
|
|
2016-11-08 23:04:11 +00:00
|
|
|
// CheckError is a helper function for panicing on errors which we need to handle
|
|
|
|
// but should be very rare e.g. failures deserializing a protobuf object that
|
|
|
|
// should only happen if there was a bug in the underlying library.
|
2016-06-27 01:56:23 +00:00
|
|
|
func CheckError(err error) {
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("%v", err))
|
|
|
|
}
|
|
|
|
}
|