From 7807cae93dadf4772828d465b0a367095e4dcd46 Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 9 Oct 2019 20:51:43 +0100 Subject: Make confgraph and graph in general more resilient to bad input --- graph.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'graph.go') diff --git a/graph.go b/graph.go index 955abbd..1604d06 100644 --- a/graph.go +++ b/graph.go @@ -1,6 +1,7 @@ package bookpipeline import ( + "errors" "fmt" "io" "path/filepath" @@ -61,6 +62,10 @@ func Graph(confs map[string]*Conf, bookname string, w io.Writer) error { } sort.Slice(graphconf, func(i, j int) bool { return graphconf[i].Pgnum < graphconf[j].Pgnum }) + if len(graphconf) == 0 { + return errors.New("No valid confidences") + } + // Create main xvalues and yvalues, annotations and ticks var xvalues, yvalues []float64 var annotations []chart.Value2 -- cgit v1.2.1-24-ge1ad