package xturbo import "errors" var ( // ErrMalformed reports bytes from the server or a local file that do not // follow the wire format (truncated, impossible lengths). ErrMalformed = errors.New("xturbo: malformed data") // ErrSetupFailed is wrapped by SetupError when the server refuses the // connection. ErrSetupFailed = errors.New("xturbo: connection setup failed") ) // Setup reply status bytes (xproto Setup*.status). const ( setupStatusFailed = 0 setupStatusSuccess = 1 setupStatusAuthenticate = 2 ) // SetupError is the server's refusal of the connection setup: Status 0 // (Failed) or 2 (Authenticate), with the server's reason. It wraps // ErrSetupFailed. type SetupError struct { Status uint8 Reason string } func (e *SetupError) Error() string { kind := "failed" if e.Status == setupStatusAuthenticate { kind = "authenticate" } return "xturbo: connection setup " + kind + ": " + e.Reason } func (e *SetupError) Unwrap() error { return ErrSetupFailed }