Skip to content

Commit

Permalink
chore: don't panic
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Aug 16, 2024
1 parent 3df2d23 commit b13ee59
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (a *App) Start() {
}

func (a *App) GoRefreshConsensus() {
defer a.HandlePanic()

a.RefreshConsensus()

ticker := time.NewTicker(a.Config.RefreshRate)
Expand Down Expand Up @@ -100,6 +102,8 @@ func (a *App) RefreshConsensus() {
}

func (a *App) GoRefreshValidators() {
defer a.HandlePanic()

a.RefreshValidators()

ticker := time.NewTicker(a.Config.ValidatorsRefreshRate)
Expand Down Expand Up @@ -132,6 +136,8 @@ func (a *App) RefreshValidators() {
}

func (a *App) GoRefreshChainInfo() {
defer a.HandlePanic()

a.RefreshChainInfo()

ticker := time.NewTicker(a.Config.ChainInfoRefreshRate)
Expand Down Expand Up @@ -166,6 +172,8 @@ func (a *App) RefreshChainInfo() {
}

func (a *App) GoRefreshUpgrade() {
defer a.HandlePanic()

a.RefreshUpgrade()

ticker := time.NewTicker(a.Config.UpgradeRefreshRate)
Expand Down Expand Up @@ -211,6 +219,8 @@ func (a *App) RefreshUpgrade() {
}

func (a *App) GoRefreshBlockTime() {
defer a.HandlePanic()

a.RefreshBlockTime()

ticker := time.NewTicker(a.Config.BlockTimeRefreshRate)
Expand Down Expand Up @@ -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)
}
}

0 comments on commit b13ee59

Please sign in to comment.