mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
refactor : Refactor error handling to use dry/usefulerror (#283)
* update the go.sum Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com> * migrate most of the files to dry errors Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com> * update the rest of the files Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com> * fixs the review comments Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com> * chores Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com> --------- Signed-off-by: DivyanshuVortex <divyanshuchandra9027@gmail.com> Co-authored-by: Abhisek Datta <abhisek.datta@gmail.com>
This commit is contained in:
co-authored by
Abhisek Datta
parent
e5fe0df82e
commit
20e01d5cae
+6
-5
@@ -4,7 +4,8 @@ import (
|
||||
"github.com/safedep/dry/cloud"
|
||||
"github.com/safedep/dry/log"
|
||||
"github.com/safedep/pmg/internal/ui"
|
||||
"github.com/safedep/pmg/usefulerror"
|
||||
"github.com/safedep/dry/usefulerror"
|
||||
"github.com/safedep/pmg/errcodes"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -19,9 +20,9 @@ func newLogoutCommand() *cobra.Command {
|
||||
func runLogout(cmd *cobra.Command, args []string) error {
|
||||
store, err := cloud.NewKeychainCredentialStore()
|
||||
if err != nil {
|
||||
ui.ErrorExit(usefulerror.Useful().
|
||||
ui.ErrorExit(usefulerror.NewUsefulError().
|
||||
Wrap(err).
|
||||
WithCode(usefulerror.ErrCodeLifecycle).
|
||||
WithCode(errcodes.Lifecycle).
|
||||
WithHumanError("Failed to initialize credential store").
|
||||
WithHelp("Your system may not support secure credential storage"))
|
||||
}
|
||||
@@ -32,9 +33,9 @@ func runLogout(cmd *cobra.Command, args []string) error {
|
||||
}()
|
||||
|
||||
if err := store.Clear(); err != nil {
|
||||
ui.ErrorExit(usefulerror.Useful().
|
||||
ui.ErrorExit(usefulerror.NewUsefulError().
|
||||
Wrap(err).
|
||||
WithCode(usefulerror.ErrCodeLifecycle).
|
||||
WithCode(errcodes.Lifecycle).
|
||||
WithHumanError("Failed to clear credentials"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user