Documentation
¶
Overview ¶
Package errors defines the error handling used by kpt codebase.
Index ¶
Constants ¶
const ( FnExecErrorTruncateLines = 4 // FnExecErrorIndentation is the number of spaces at the beginning of each // line of function failure messages. FnExecErrorIndentation = 2 )
Variables ¶
This section is empty.
Functions ¶
func As ¶
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true. Otherwise, it returns false.
func UnwrapErrors ¶
UnwrapErrors unwraps any *Error errors in the chain and returns the first error it finds that is of a different type. If no such error can be found, the last return value will be false. nolint
func UnwrapKioError ¶
UnwrapKioError unwraps the error returned by kio pipeline. The error returned by kio pipeline is wrapped by library 'github.com/go-errors/errors' and it doesn't support 'Unwrap' method so 'errors.As' will not work. This function will return the first error wrapped by kio pipeline. If the error is not wrapped by kio pipeline, it will return the original error.
Types ¶
type Class ¶
type Class int
Class describes the class of errors encountered.
const ( Other Class = iota // Unclassified. Will not be printed. Exist // Item already exists. Internal // Internal error. InvalidParam // Value is not valid. MissingParam // Required value is missing or empty. Git // Errors from Git IO // Error doing IO operations YAML // yaml document can't be parsed )
type Error ¶
type Error struct {
// Path is the path of the object (pkg, file) involved in kpt operation.
Path types.UniquePath
// Op is the operation being performed, for ex. pkg.get, fn.render
Op Op
// Fn is the kpt function being run either as part of "fn render" or "fn eval"
Fn Fn
// Repo is the git repo used for get, update or diff
Repo Repo
// Class refers to class of errors
Class Class
// Err refers to wrapped error (if any)
Err error
}
Error is the type that implements error interface used in the kpt codebase. It is based on the design in https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html The intent is to capture error information in a structured format so that we can display it differently to different users for ex. kpt developers are interested in operational trace along with more diagnostic information while kpt end-users may be just interested in a concise and actionable information. Representing errors in structured format helps us decouple the error information from how it is surfaced to the end users.
type FnExecError ¶
type FnExecError struct {
// OriginalErr is the original error returned from function runtime
OriginalErr error
// TruncateOutput indicates should error message be truncated
TruncateOutput bool
// Stderr is the content written to function stderr
Stderr string `yaml:"stderr,omitempty"`
// ExitCode is the exit code returned from function
ExitCode int `yaml:"exitCode,omitempty"`
}
FnExecError contains the information about the function failure that will be outputted.
func (*FnExecError) Error ¶
func (fe *FnExecError) Error() string
func (*FnExecError) String ¶
func (fe *FnExecError) String() string
String returns string representation of the failure.