diff --git a/ted/calendar.go b/ted/calendar.go index dc413b9..0c4cc4a 100644 --- a/ted/calendar.go +++ b/ted/calendar.go @@ -27,9 +27,20 @@ func GetOJS(baseURL string, year int, date string) (string, error) { defer resp.Body.Close() // read CSV - body, _ := io.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) + if err != nil { + return ojs, err + } + reader := csv.NewReader(bytes.NewReader(body)) - records, _ := reader.ReadAll() + records, err := reader.ReadAll() + if err != nil { + return ojs, err + } + + if len(records) < 2 { + return ojs, fmt.Errorf("ojs calendar is empty") + } for _, row := range records[1:] { rowDate := strings.TrimSpace(row[1])