github.com/noirx94/tendermintmp@v0.0.1/privval/errors.go (about)

     1  package privval
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  // EndpointTimeoutError occurs when endpoint times out.
     9  type EndpointTimeoutError struct{}
    10  
    11  // Implement the net.Error interface.
    12  func (e EndpointTimeoutError) Error() string   { return "endpoint connection timed out" }
    13  func (e EndpointTimeoutError) Timeout() bool   { return true }
    14  func (e EndpointTimeoutError) Temporary() bool { return true }
    15  
    16  // Socket errors.
    17  var (
    18  	ErrConnectionTimeout  = EndpointTimeoutError{}
    19  	ErrNoConnection       = errors.New("endpoint is not connected")
    20  	ErrReadTimeout        = errors.New("endpoint read timed out")
    21  	ErrUnexpectedResponse = errors.New("empty response")
    22  	ErrWriteTimeout       = errors.New("endpoint write timed out")
    23  )
    24  
    25  // RemoteSignerError allows (remote) validators to include meaningful error
    26  // descriptions in their reply.
    27  type RemoteSignerError struct {
    28  	// TODO(ismail): create an enum of known errors
    29  	Code        int
    30  	Description string
    31  }
    32  
    33  func (e *RemoteSignerError) Error() string {
    34  	return fmt.Sprintf("signerEndpoint returned error #%d: %s", e.Code, e.Description)
    35  }