github.com/storacha/go-ucanto@v0.7.2/server/retrieval/error.go (about)

     1  package retrieval
     2  
     3  import (
     4  	"github.com/storacha/go-ucanto/core/ipld"
     5  	rdm "github.com/storacha/go-ucanto/server/retrieval/datamodel"
     6  )
     7  
     8  type AgentMessageInvocationCountError struct{}
     9  
    10  func (amie AgentMessageInvocationCountError) Error() string {
    11  	return "Agent Message is required to have a single invocation."
    12  }
    13  
    14  func (amie AgentMessageInvocationCountError) Name() string {
    15  	return "AgentMessageInvocationError"
    16  }
    17  
    18  func (amie AgentMessageInvocationCountError) ToIPLD() (ipld.Node, error) {
    19  	mdl := rdm.AgentMessageInvocationErrorModel{
    20  		Name:    amie.Name(),
    21  		Message: amie.Error(),
    22  	}
    23  	return ipld.WrapWithRecovery(&mdl, rdm.AgentMessageInvocationErrorType())
    24  }
    25  
    26  func NewAgentMessageInvocationCountError() AgentMessageInvocationCountError {
    27  	return AgentMessageInvocationCountError{}
    28  }
    29  
    30  type MissingProofs struct {
    31  	proofs []ipld.Link
    32  }
    33  
    34  func (mpe MissingProofs) Error() string {
    35  	return "proofs were missing, resubmit the invocation with the requested proofs"
    36  }
    37  
    38  func (mpe MissingProofs) Name() string {
    39  	return "MissingProofs"
    40  }
    41  
    42  func (mpe MissingProofs) Proofs() []ipld.Link {
    43  	return mpe.proofs
    44  }
    45  
    46  func (mpe MissingProofs) ToIPLD() (ipld.Node, error) {
    47  	mdl := rdm.MissingProofsModel{
    48  		Name:    mpe.Name(),
    49  		Message: mpe.Error(),
    50  		Proofs:  mpe.Proofs(),
    51  	}
    52  	return ipld.WrapWithRecovery(&mdl, rdm.MissingProofsType())
    53  }
    54  
    55  func NewMissingProofsError(proofs []ipld.Link) MissingProofs {
    56  	return MissingProofs{proofs}
    57  }