π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add common recover with logs
Neeraj Gupta2c9b0ea7a9d6
diff --git a/cmd/account.go b/cmd/account.goindex 454d966a6c..0ea4141794 100644--- a/cmd/account.go+++ b/cmd/account.go@@ -17,6 +17,7 @@ var listAccCmd = &cobra.Command{Use: "list",Short: "list configured accounts",RunE: func(cmd *cobra.Command, args []string) error {+ recoverWithLog()return ctrl.ListAccounts(context.Background())},}@@ -26,6 +27,7 @@ var addAccCmd = &cobra.Command{Use: "add",Short: "Add a new account",Run: func(cmd *cobra.Command, args []string) {+ recoverWithLog()ctrl.AddAccount(context.Background())},}@@ -34,7 +36,6 @@ func init() {// Add 'config' subcommands to the root commandrootCmd.AddCommand(accountCmd)-// Add 'config' subcommands to the 'config' commandaccountCmd.AddCommand(listAccCmd, addAccCmd)}diff --git a/cmd/root.go b/cmd/root.goindex 0b30ea92fd..8001465bac 100644--- a/cmd/root.go+++ b/cmd/root.go@@ -4,6 +4,7 @@ import ("cli-go/pkg""fmt""os"+ "runtime""github.com/spf13/viper"@@ -50,3 +51,13 @@ func init() {viper.AddConfigPath(".") // Search for config file in the current directoryviper.ReadInConfig() // Read the configuration file if it exists}++func recoverWithLog() {+ if r := recover(); r != nil {+ fmt.Println("Panic occurred:", r)+ // Print the stack trace+ stackTrace := make([]byte, 1024*8)+ stackTrace = stackTrace[:runtime.Stack(stackTrace, false)]+ fmt.Printf("Stack Trace:\n%s", stackTrace)+ }+}