Skip to content

Commit a663fc9

Browse files
committed
Keep same error handling for main cli plugin execution
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
1 parent 2cceb97 commit a663fc9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/root/root.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ We collect anonymous usage data to help improve cagent. To disable:
179179
}
180180
return nil
181181
}
182+
if rootCmd.RunE != nil {
183+
originalRunE := rootCmd.RunE
184+
rootCmd.RunE = func(cmd *cobra.Command, args []string) error {
185+
if err := originalRunE(cmd, args); err != nil {
186+
return processErr(rootCmd.Context(), err, stderr, rootCmd)
187+
}
188+
return nil
189+
}
190+
}
182191
return rootCmd
183192
}, metadata.Metadata{
184193
SchemaVersion: "0.1.0",

0 commit comments

Comments
 (0)