/ internal / executor / errors.go
errors.go
  1  package executor
  2  
  3  import "fmt"
  4  
  5  type Error struct {
  6  	message string
  7  }
  8  
  9  func (e Error) Error() string {
 10  	return e.message
 11  }
 12  
 13  type FlagNotSetError struct {
 14  	flagText string
 15  }
 16  
 17  func (e FlagNotSetError) Error() string {
 18  	return "please use the required --" + e.flagText + " flag"
 19  }
 20  
 21  type UnsupportedTypeError struct {
 22  	resourceType string
 23  }
 24  
 25  func (e UnsupportedTypeError) Error() string {
 26  	return "'" + e.resourceType + "' is not supported for this operation"
 27  }
 28  
 29  type NoAccountSpecifiedError struct{}
 30  
 31  func (e NoAccountSpecifiedError) Error() string {
 32  	return "no account specified in this request"
 33  }
 34  
 35  type UnsupportedAddOperationError struct {
 36  	resourceType      string
 37  	addToResourceType string
 38  }
 39  
 40  func (e UnsupportedAddOperationError) Error() string {
 41  	return "adding '" +
 42  		e.resourceType +
 43  		"' to '" +
 44  		e.addToResourceType +
 45  		"' is not supported"
 46  }
 47  
 48  type UnsupportedRemoveOperationError struct {
 49  	resourceType           string
 50  	removeFromResourceType string
 51  }
 52  
 53  func (e UnsupportedRemoveOperationError) Error() string {
 54  	return "removing '" +
 55  		e.resourceType +
 56  		"' from '" +
 57  		e.removeFromResourceType +
 58  		"' is not supported"
 59  }
 60  
 61  type UnsupportedShowOperationError struct {
 62  	resourceType         string
 63  	showFromResourceType string
 64  }
 65  
 66  func (e UnsupportedShowOperationError) Error() string {
 67  	return "showing '" +
 68  		e.resourceType +
 69  		"' from '" +
 70  		e.showFromResourceType +
 71  		"' is not supported"
 72  }
 73  
 74  type UnknownCommandError struct {
 75  	command string
 76  }
 77  
 78  func (e UnknownCommandError) Error() string {
 79  	return "unknown command '" + e.command + "'"
 80  }
 81  
 82  type NotFollowingError struct {
 83  	account string
 84  }
 85  
 86  func (e NotFollowingError) Error() string {
 87  	return "you are not following " + e.account
 88  }
 89  
 90  type MismatchedNumMediaValuesError struct {
 91  	valueType     string
 92  	numValues     int
 93  	numMediaFiles int
 94  }
 95  
 96  func (e MismatchedNumMediaValuesError) Error() string {
 97  	return fmt.Sprintf(
 98  		"unexpected number of %s: received %d media files but got %d %s",
 99  		e.valueType,
100  		e.numMediaFiles,
101  		e.numValues,
102  		e.valueType,
103  	)
104  }
105  
106  type UnexpectedNumValuesError struct {
107  	name     string
108  	actual   int
109  	expected int
110  }
111  
112  func (e UnexpectedNumValuesError) Error() string {
113  	return fmt.Sprintf(
114  		"received an unexpected number of %s: received %d, expected %d",
115  		e.name,
116  		e.actual,
117  		e.expected,
118  	)
119  }
120  
121  type MissingIDError struct {
122  	resource string
123  	action   string
124  }
125  
126  func (e MissingIDError) Error() string {
127  	return "please provide the ID of the " + e.resource + " you want to " + e.action
128  }