github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/light/provider/errors.go (about)

     1  package provider
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  var (
     9  	// ErrHeightTooHigh is returned when the height is higher than the last
    10  	// block that the provider has. The light client will not remove the provider
    11  	ErrHeightTooHigh = errors.New("height requested is too high")
    12  	// ErrLightBlockNotFound is returned when a provider can't find the
    13  	// requested header (i.e. it has been pruned).
    14  	// The light client will not remove the provider
    15  	ErrLightBlockNotFound = errors.New("light block not found")
    16  	// ErrNoResponse is returned if the provider doesn't respond to the
    17  	// request in a given time. The light client will not remove the provider
    18  	ErrNoResponse = errors.New("client failed to respond")
    19  	// ErrConnectionClosed is returned if the provider closes the connection.
    20  	// In this case we remove the provider.
    21  	ErrConnectionClosed = errors.New("client closed connection")
    22  )
    23  
    24  // ErrBadLightBlock is returned when a provider returns an invalid
    25  // light block. The light client will remove the provider.
    26  type ErrBadLightBlock struct {
    27  	Reason error
    28  }
    29  
    30  func (e ErrBadLightBlock) Error() string {
    31  	return fmt.Sprintf("client provided bad signed header: %v", e.Reason)
    32  }
    33  
    34  func (e ErrBadLightBlock) Unwrap() error { return e.Reason }
    35  
    36  // ErrUnreliableProvider is a generic error that indicates that the provider isn't
    37  // behaving in a reliable manner to the light client. The light client will
    38  // remove the provider
    39  type ErrUnreliableProvider struct {
    40  	Reason error
    41  }
    42  
    43  func (e ErrUnreliableProvider) Error() string {
    44  	return fmt.Sprintf("client deemed unreliable: %v", e.Reason)
    45  }
    46  
    47  func (e ErrUnreliableProvider) Unwrap() error { return e.Reason }