Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AuthRemediation = fmt.Sprintf(strings.Join([]string{ "This error may be caused by a missing, incorrect, or expired Fastly API token.", "Check that you're supplying a valid token, either via --token,", "through the environment variable %s, or through the config file via `fastly configure`.", "Verify that the token is still valid via `fastly whoami`.", }, " "), config.EnvVarToken)
AuthRemediation suggests checking the provided --token.
var BugRemediation = strings.Join([]string{
"If you believe this error is the result of a bug, please file an issue:",
"https://github.com/fastly/cli/issues/new?labels=bug&template=bug_report.md",
}, " ")
BugRemediation suggests filing a bug on the GitHub repo. It's good to include as the final suggested remediation in many errors.
var ErrNoServiceID = RemediationError{Inner: fmt.Errorf("error reading service: no service ID found"), Remediation: ServiceIDRemediation}
ErrNoServiceID means no --service-id or service_id package manifest value has been provided.
var ErrNoToken = RemediationError{Inner: fmt.Errorf("no token provided"), Remediation: AuthRemediation}
ErrNoToken means no --token has been provided.
var HostRemediation = strings.Join([]string{
"This error may be caused by a problem with your host environment, for example",
"too-restrictive file permissions, files that already exist, or a full disk.",
}, " ")
HostRemediation suggests there might be an issue with the local host.
var NetworkRemediation = strings.Join([]string{
"This error may be caused by transient network issues.",
"Please verify your network connection and try again.",
}, " ")
NetworkRemediation suggests, somewhat unhelpfully, to try again later.
var ServiceIDRemediation = strings.Join([]string{
"Please provide one via the --service-id flag or within your package manifest",
}, " ")
ServiceIDRemediation suggests provide a service ID via --service-id flag or package manifest.
Functions ¶
func SimplifyFastlyError ¶
SimplifyFastlyError reduces the potentially complex and multi-line Error rendering of a fastly.HTTPError to something more palatable for a CLI.
Types ¶
type RemediationError ¶
RemediationError wraps a normal error with a suggested remediation.
func Deduce ¶
func Deduce(err error) RemediationError
Deduce attempts to deduce a RemediationError from a plain error. If the error is already a RemediationError it is returned directly. Certain deep error types, like a Fastly SDK HTTPError, are detected and converted in appropriate cases to e.g. AuthRemediation. If no specific remediation can be suggested, a remediation to file a bug is used.
func (RemediationError) Error ¶
func (re RemediationError) Error() string
Error prints the inner error string without any remediation suggestion.
func (RemediationError) Print ¶
func (re RemediationError) Print(w io.Writer)
Print the error to the io.Writer for human consumption. If a prefix is provided, it will be written without modification. The inner error is always printed via text.Output with an "Error: " prefix and a "." suffix. If a remediation is provided, it's printed via text.Output.
func (RemediationError) Unwrap ¶
func (re RemediationError) Unwrap() error
Unwrap returns the inner error.