Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cmd/d8/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"github.com/deckhouse/deckhouse-cli/internal/tools"
useroperation "github.com/deckhouse/deckhouse-cli/internal/useroperation/cmd"
"github.com/deckhouse/deckhouse-cli/internal/version"
"github.com/deckhouse/deckhouse-cli/pkg/diagnostic"
)

type RootCommand struct {
Expand Down Expand Up @@ -174,7 +175,15 @@ func (r *RootCommand) Execute() error {
func execute() {
rootCmd := NewRootCommand()
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error executing command: %v\n", err)
// If a command returned a HelpfulError, show formatted diagnostic.
// Commands are responsible for classifying their own errors using
// domain-specific errdetect packages (e.g. errdetect.Diagnose for mirror).
var helpErr *diagnostic.HelpfulError
if errors.As(err, &helpErr) {
fmt.Fprint(os.Stderr, helpErr.Format())
} else {
fmt.Fprintf(os.Stderr, "Error executing command: %v\n", err)
}
os.Exit(1)
}
}
Loading
Loading