...

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

Documentation: github.com/theupdateframework/go-tuf/client

     1  package client
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  var (
     9  	ErrNoRootKeys       = errors.New("tuf: no root keys found in local meta store")
    10  	ErrInsufficientKeys = errors.New("tuf: insufficient keys to meet threshold")
    11  	ErrNoLocalSnapshot  = errors.New("tuf: no snapshot stored locally")
    12  )
    13  
    14  type ErrMissingRemoteMetadata struct {
    15  	Name string
    16  }
    17  
    18  func (e ErrMissingRemoteMetadata) Error() string {
    19  	return fmt.Sprintf("tuf: missing remote metadata %s", e.Name)
    20  }
    21  
    22  type ErrDownloadFailed struct {
    23  	File string
    24  	Err  error
    25  }
    26  
    27  func (e ErrDownloadFailed) Error() string {
    28  	return fmt.Sprintf("tuf: failed to download %s: %s", e.File, e.Err)
    29  }
    30  
    31  type ErrDecodeFailed struct {
    32  	File string
    33  	Err  error
    34  }
    35  
    36  func (e ErrDecodeFailed) Error() string {
    37  	return fmt.Sprintf("tuf: failed to decode %s: %s", e.File, e.Err)
    38  }
    39  
    40  type ErrMaxDelegations struct {
    41  	Target          string
    42  	MaxDelegations  int
    43  	SnapshotVersion int64
    44  }
    45  
    46  func (e ErrMaxDelegations) Error() string {
    47  	return fmt.Sprintf("tuf: max delegation of %d reached searching for %s with snapshot version %d", e.MaxDelegations, e.Target, e.SnapshotVersion)
    48  }
    49  
    50  type ErrNotFound struct {
    51  	File string
    52  }
    53  
    54  func (e ErrNotFound) Error() string {
    55  	return fmt.Sprintf("tuf: file not found: %s", e.File)
    56  }
    57  
    58  func IsNotFound(err error) bool {
    59  	_, ok := err.(ErrNotFound)
    60  	return ok
    61  }
    62  
    63  type ErrWrongSize struct {
    64  	File     string
    65  	Actual   int64
    66  	Expected int64
    67  }
    68  
    69  func (e ErrWrongSize) Error() string {
    70  	return fmt.Sprintf("tuf: unexpected file size: %s (expected %d bytes, got %d bytes)", e.File, e.Expected, e.Actual)
    71  }
    72  
    73  type ErrUnknownTarget struct {
    74  	Name            string
    75  	SnapshotVersion int64
    76  }
    77  
    78  func (e ErrUnknownTarget) Error() string {
    79  	return fmt.Sprintf("tuf: unknown target file: %s with snapshot version %d", e.Name, e.SnapshotVersion)
    80  }
    81  
    82  type ErrMetaTooLarge struct {
    83  	Name    string
    84  	Size    int64
    85  	MaxSize int64
    86  }
    87  
    88  func (e ErrMetaTooLarge) Error() string {
    89  	return fmt.Sprintf("tuf: %s size %d bytes greater than maximum %d bytes", e.Name, e.Size, e.MaxSize)
    90  }
    91  
    92  type ErrInvalidURL struct {
    93  	URL string
    94  }
    95  
    96  func (e ErrInvalidURL) Error() string {
    97  	return fmt.Sprintf("tuf: invalid repository URL %s", e.URL)
    98  }
    99  
   100  type ErrRoleNotInSnapshot struct {
   101  	Role            string
   102  	SnapshotVersion int64
   103  }
   104  
   105  func (e ErrRoleNotInSnapshot) Error() string {
   106  	return fmt.Sprintf("tuf: role %s not in snapshot version %d", e.Role, e.SnapshotVersion)
   107  }
   108  

View as plain text