From b13ee59f4bc36dee9b6d0a21104dbe45f99d4b73 Mon Sep 17 00:00:00 2001 From: Sergey Date: Fri, 16 Aug 2024 13:10:54 +0300 Subject: [PATCH] chore: don't panic --- pkg/app.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/app.go b/pkg/app.go index a10cd33..0a91d61 100644 --- a/pkg/app.go +++ b/pkg/app.go @@ -59,6 +59,8 @@ func (a *App) Start() { } func (a *App) GoRefreshConsensus() { + defer a.HandlePanic() + a.RefreshConsensus() ticker := time.NewTicker(a.Config.RefreshRate) @@ -100,6 +102,8 @@ func (a *App) RefreshConsensus() { } func (a *App) GoRefreshValidators() { + defer a.HandlePanic() + a.RefreshValidators() ticker := time.NewTicker(a.Config.ValidatorsRefreshRate) @@ -132,6 +136,8 @@ func (a *App) RefreshValidators() { } func (a *App) GoRefreshChainInfo() { + defer a.HandlePanic() + a.RefreshChainInfo() ticker := time.NewTicker(a.Config.ChainInfoRefreshRate) @@ -166,6 +172,8 @@ func (a *App) RefreshChainInfo() { } func (a *App) GoRefreshUpgrade() { + defer a.HandlePanic() + a.RefreshUpgrade() ticker := time.NewTicker(a.Config.UpgradeRefreshRate) @@ -211,6 +219,8 @@ func (a *App) RefreshUpgrade() { } func (a *App) GoRefreshBlockTime() { + defer a.HandlePanic() + a.RefreshBlockTime() ticker := time.NewTicker(a.Config.BlockTimeRefreshRate) @@ -254,3 +264,10 @@ func (a *App) ListenForPause() { a.IsPaused = paused } } + +func (a *App) HandlePanic() { + if r := recover(); r != nil { + a.DisplayWrapper.App.Stop() + panic(r) + } +}