github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/tm2/pkg/bft/privval/errors.go (about)

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