From 627f609023509cebe70f9baa76b31ce87d4a952b Mon Sep 17 00:00:00 2001 From: Robert Jonczy Date: Tue, 30 Apr 2024 00:28:46 +0200 Subject: [PATCH] do not panic --- proposals.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proposals.go b/proposals.go index ccae820..3864a0a 100644 --- a/proposals.go +++ b/proposals.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "fmt" "io" "net/http" ) @@ -64,5 +65,8 @@ func getLatestProposal(cosmosEndpoint string) (*Proposal, error) { if err != nil { return nil, err } + if len(proposalsData.Proposals) == 0 { + return nil, fmt.Errorf("no proposals found") + } return &proposalsData.Proposals[0], nil }