...

Source file src/github.com/theupdateframework/go-tuf/errors.go

Documentation: github.com/theupdateframework/go-tuf

     1  package tuf
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  	"time"
     7  )
     8  
     9  var (
    10  	ErrInitNotAllowed               = errors.New("tuf: repository already initialized")
    11  	ErrNewRepository                = errors.New("tuf: repository not yet committed")
    12  	ErrChangePassphraseNotSupported = errors.New("tuf: store does not support changing passphrase")
    13  )
    14  
    15  type ErrMissingMetadata struct {
    16  	Name string
    17  }
    18  
    19  func (e ErrMissingMetadata) Error() string {
    20  	return fmt.Sprintf("tuf: missing metadata file %s", e.Name)
    21  }
    22  
    23  type ErrFileNotFound struct {
    24  	Path string
    25  }
    26  
    27  func (e ErrFileNotFound) Error() string {
    28  	return fmt.Sprintf("tuf: file not found %s", e.Path)
    29  }
    30  
    31  type ErrNoKeys struct {
    32  	Name string
    33  }
    34  
    35  func (e ErrNoKeys) Error() string {
    36  	return fmt.Sprintf("tuf: no keys available to sign %s", e.Name)
    37  }
    38  
    39  type ErrInsufficientSignatures struct {
    40  	Name string
    41  	Err  error
    42  }
    43  
    44  func (e ErrInsufficientSignatures) Error() string {
    45  	return fmt.Sprintf("tuf: insufficient signatures for %s: %s", e.Name, e.Err)
    46  }
    47  
    48  type ErrInvalidRole struct {
    49  	Role   string
    50  	Reason string
    51  }
    52  
    53  func (e ErrInvalidRole) Error() string {
    54  	return fmt.Sprintf("tuf: invalid role %s: %s", e.Role, e.Reason)
    55  }
    56  
    57  type ErrInvalidExpires struct {
    58  	Expires time.Time
    59  }
    60  
    61  func (e ErrInvalidExpires) Error() string {
    62  	return fmt.Sprintf("tuf: invalid expires: %s", e.Expires)
    63  }
    64  
    65  type ErrKeyNotFound struct {
    66  	Role  string
    67  	KeyID string
    68  }
    69  
    70  func (e ErrKeyNotFound) Error() string {
    71  	return fmt.Sprintf(`tuf: no key with id "%s" exists for the %s role`, e.KeyID, e.Role)
    72  }
    73  
    74  type ErrNotEnoughKeys struct {
    75  	Role      string
    76  	Keys      int
    77  	Threshold int
    78  }
    79  
    80  func (e ErrNotEnoughKeys) Error() string {
    81  	return fmt.Sprintf("tuf: %s role has insufficient keys for threshold (has %d keys, threshold is %d)", e.Role, e.Keys, e.Threshold)
    82  }
    83  
    84  type ErrPassphraseRequired struct {
    85  	Role string
    86  }
    87  
    88  func (e ErrPassphraseRequired) Error() string {
    89  	return fmt.Sprintf("tuf: a passphrase is required to access the encrypted %s keys file", e.Role)
    90  }
    91  
    92  type ErrNoDelegatedTarget struct {
    93  	Path string
    94  }
    95  
    96  func (e ErrNoDelegatedTarget) Error() string {
    97  	return fmt.Sprintf("tuf: no delegated target for path %s", e.Path)
    98  }
    99  

View as plain text