INNER CODE UNIT · Go

handleErr

kptdev/kpt · main.go:67

func handleErr(cmd *cobra.Command, err error) int {
	// First attempt to see if we can resolve the error into a specific
	// error message.
	if re, resolved := resolver.ResolveError(err); resolved {
		if re.Message != "" {
			fmt.Fprintf(cmd.ErrOrStderr(), "%s \n", re.Message)
		}
		return re.ExitCode
	}

	// Then try to see if it is of type *errors.Error
	var kptErr *errors.Error
	if errors.As(err, &kptErr) {
		unwrapped, ok := errors.UnwrapErrors(kptErr)
		if ok && !cmdutil.PrintErrorStacktrace() {
			fmt.Fprintf(cmd.ErrOrStderr(), "Error: %s \n", unwrapped.Error())
			return 1
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…