github.com/filecoin-project/lassie@v0.23.0/pkg/events/failed.go (about)

     1  package events
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  
     7  	"github.com/filecoin-project/lassie/pkg/types"
     8  )
     9  
    10  var (
    11  	_ types.RetrievalEvent  = FailedEvent{}
    12  	_ EventWithErrorMessage = FailedEvent{}
    13  )
    14  
    15  type FailedEvent struct {
    16  	retrievalEvent
    17  	errorMessage string
    18  }
    19  
    20  func (e FailedEvent) Code() types.EventCode { return types.FailedCode }
    21  func (e FailedEvent) ErrorMessage() string  { return e.errorMessage }
    22  func (e FailedEvent) String() string {
    23  	return fmt.Sprintf("FailedEvent<%s, %s, %s, %v>", e.eventTime, e.retrievalId, e.rootCid, e.errorMessage)
    24  }
    25  
    26  func Failed(at time.Time, retrievalId types.RetrievalID, candidate types.RetrievalCandidate, errorMessage string) FailedEvent {
    27  	return FailedEvent{retrievalEvent{at, retrievalId, candidate.RootCid}, errorMessage}
    28  }