recoverPanic handles any panics during program execution and logs the error using Logrus.
()
| 43 | |
| 44 | // recoverPanic handles any panics during program execution and logs the error using Logrus. |
| 45 | func recoverPanic() { |
| 46 | if rec := recover(); rec != nil { |
| 47 | logrus.Error(rec) // Log the recovered panic |
| 48 | os.Exit(1) // Exit the program with an error status |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // preRun sets up the configuration and initializes the LedgerForge instance before running any command. |
| 53 | // It ensures that the configuration is loaded, and the LedgerForge instance is initialized properly. |