Skip to content

Commit

Permalink
Improve error logging
Browse files Browse the repository at this point in the history
Signed-off-by: David Cassany <[email protected]>
  • Loading branch information
davidcassany committed Jul 9, 2024
1 parent 176d2b6 commit 920edcb
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 8 deletions.
7 changes: 6 additions & 1 deletion cmd/build-disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ func NewBuildDisk(root *cobra.Command, addCheckRoot bool) *cobra.Command {
cfg.Logger.Errorf("failed to initialize build disk action: %v", err)
return err
}
return builder.BuildDiskRun()

err = builder.BuildDiskRun()
if err != nil {
cfg.Logger.Errorf("build-disk command failed: %v", err)
}
return err
},
}
root.AddCommand(c)
Expand Down
7 changes: 6 additions & 1 deletion cmd/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ func NewBuildISO(root *cobra.Command, addCheckRoot bool) *cobra.Command {
}

buildISO := action.NewBuildISOAction(cfg, spec)
return buildISO.Run()
err = buildISO.Run()
if err != nil {
cfg.Logger.Errorf("build-iso command failed: %v", err)
}

return err
},
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/cloud-init.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func NewCloudInitCmd(root *cobra.Command) *cobra.Command {
}

err = cfg.CloudInitRunner.Run(stage, args...)
if err != nil {
cfg.Logger.Errorf("cloud-init command failed: %v")
}

return elementalError.NewFromError(err, elementalError.CloudInitRunStage)
},
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ func InitCmd(root *cobra.Command) *cobra.Command {
}

cfg.Logger.Infof("Initializing system...")
return action.RunInit(cfg, spec)
err = action.RunInit(cfg, spec)
if err != nil {
cfg.Logger.Errorf("init command failed: %v", err)
}
return err
},
}
root.AddCommand(c)
Expand Down
6 changes: 5 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ func NewInstallCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
cfg.Logger.Errorf("failed to initialize install action: %v", err)
return err
}
return install.Run()
err = install.Run()
if err != nil {
cfg.Logger.Errorf("install command failed: %v", err)
}
return err
},
}
firmType := newEnumFlag([]string{types.EFI}, types.EFI)
Expand Down
7 changes: 6 additions & 1 deletion cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ func NewMountCmd(root *cobra.Command) *cobra.Command {
}

cfg.Logger.Info("Mounting system...")
return action.RunMount(cfg, spec)
err = action.RunMount(cfg, spec)
if err != nil {
cfg.Logger.Errorf("mount command failed: %v", err)
}

return err
},
}
root.AddCommand(c)
Expand Down
8 changes: 7 additions & 1 deletion cmd/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ func NewResetCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
cfg.Logger.Errorf("failed to initialize reset action: %v", err)
return err
}
return reset.Run()

err = reset.Run()
if err != nil {
cfg.Logger.Errorf("reset command failed: %v", err)
}

return err
},
}
root.AddCommand(c)
Expand Down
7 changes: 6 additions & 1 deletion cmd/upgrade-recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ func NewUpgradeRecoveryCmd(root *cobra.Command, addCheckRoot bool) *cobra.Comman
return err
}

return upgrade.Run()
err = upgrade.Run()
if err != nil {
cfg.Logger.Errorf("upgrade-recovery command failed: %v", err)
}

return err
},
}
root.AddCommand(c)
Expand Down
7 changes: 6 additions & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ func NewUpgradeCmd(root *cobra.Command, addCheckRoot bool) *cobra.Command {
return err
}

return upgrade.Run()
err = upgrade.Run()
if err != nil {
cfg.Logger.Errorf("upgrade command failed: %v", err)
}

return err
},
}
root.AddCommand(c)
Expand Down

0 comments on commit 920edcb

Please sign in to comment.