github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/command/v2/shared/errors.go (about)

     1  package shared
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  type JobFailedError struct {
     9  	JobGUID string
    10  	Message string
    11  }
    12  
    13  func (e JobFailedError) Error() string {
    14  	return "Job ({{.JobGUID}}) failed: {{.Message}}"
    15  }
    16  
    17  func (e JobFailedError) Translate(translate func(string, ...interface{}) string) string {
    18  	return translate(e.Error(), map[string]interface{}{
    19  		"Message": e.Message,
    20  		"JobGUID": e.JobGUID,
    21  	})
    22  }
    23  
    24  type JobTimeoutError struct {
    25  	JobGUID string
    26  	Timeout time.Duration
    27  }
    28  
    29  func (e JobTimeoutError) Error() string {
    30  	return "Job ({{.JobGUID}}) polling timeout has been reached. The operation may still be running on the CF instance. Your CF operator may have more information."
    31  }
    32  
    33  func (e JobTimeoutError) Translate(translate func(string, ...interface{}) string) string {
    34  	return translate(e.Error(), map[string]interface{}{
    35  		"JobGUID": e.JobGUID,
    36  	})
    37  }
    38  
    39  type NoOrganizationTargetedError struct{}
    40  
    41  func (e NoOrganizationTargetedError) Error() string {
    42  	return "An org must be targeted before targeting a space"
    43  }
    44  
    45  func (e NoOrganizationTargetedError) Translate(translate func(string, ...interface{}) string) string {
    46  	return translate(e.Error())
    47  }
    48  
    49  type OrganizationNotFoundError struct {
    50  	Name string
    51  }
    52  
    53  func (e OrganizationNotFoundError) Error() string {
    54  	return "Organization '{{.Name}}' not found."
    55  }
    56  
    57  func (e OrganizationNotFoundError) Translate(translate func(string, ...interface{}) string) string {
    58  	return translate(e.Error(), map[string]interface{}{
    59  		"Name": e.Name,
    60  	})
    61  }
    62  
    63  type SpaceNotFoundError struct {
    64  	Name string
    65  }
    66  
    67  func (e SpaceNotFoundError) Error() string {
    68  	return "Space '{{.Name}}' not found."
    69  }
    70  
    71  func (e SpaceNotFoundError) Translate(translate func(string, ...interface{}) string) string {
    72  	return translate(e.Error(), map[string]interface{}{
    73  		"Name": e.Name,
    74  	})
    75  }
    76  
    77  type HTTPHealthCheckInvalidError struct {
    78  }
    79  
    80  func (e HTTPHealthCheckInvalidError) Error() string {
    81  	return "Health check type must be 'http' to set a health check HTTP endpoint."
    82  }
    83  
    84  func (e HTTPHealthCheckInvalidError) Translate(translate func(string, ...interface{}) string) string {
    85  	return translate(e.Error())
    86  }
    87  
    88  type InvalidRefreshTokenError struct {
    89  }
    90  
    91  func (e InvalidRefreshTokenError) Error() string {
    92  	return "The token expired, was revoked, or the token ID is incorrect. Please log back in to re-authenticate."
    93  }
    94  
    95  func (e InvalidRefreshTokenError) Translate(translate func(string, ...interface{}) string) string {
    96  	return translate(e.Error())
    97  }
    98  
    99  type StagingFailedError struct {
   100  	Message    string
   101  	BinaryName string
   102  }
   103  
   104  func (e StagingFailedError) Error() string {
   105  	return `{{.Message}}\n\nTIP: Use '{{.BuildpackCommand}}' to see a list of supported buildpacks.`
   106  }
   107  
   108  func (e StagingFailedError) Translate(translate func(string, ...interface{}) string) string {
   109  	return translate(e.Error(), map[string]interface{}{
   110  		"Message":          e.Message,
   111  		"BuildpackCommand": fmt.Sprintf("%s buildpacks", e.BinaryName),
   112  	})
   113  }