LaMonF / FDJ_SLACK

Fetches FDJ loto data to post on SLACK
MIT License
2 stars 2 forks source link

Application Fails if full results are not yet provided by API #19

Closed LaMonF closed 5 years ago

LaMonF commented 5 years ago

When results coming from the API are not up to date yet ! application fails with :

2018/11/21 21:00:00 Info [[ Résultats du mercredi 21 novembre 2018 Numéros : 20 - 21  
    - 22 - 23 - 45 Numéro Chance : 10 Les rapports complets du tirage ne sont pas encore dd
    isponibles, le flux sera mis �|  jour dès publication des informations.]]
161 2018/11/21 21:00:00 cron: panic running job: runtime error: index out of range
162 goroutine 76 [running]:
163 github.com/robfig/cron.(*Cron).runWithRecovery.func1(0xc4200a4230)
164         /home/monf/go/src/github.com/robfig/cron/cron.go:161 +0xbc
165 panic(0x6973c0, 0x871f90)
166         /usr/lib/go-1.10/src/runtime/panic.go:502 +0x229
167 github.com/LaMonF/FDJ_SLACK/parser.(*LesBonsNumerosAPIParser).ParseData(0xc420059cc8, 0    xc420516000, 0x3e93, 0x7e00, 0x4a9252, 0xc420466000, 0x6f2025)
168         /home/monf/go/src/github.com/LaMonF/FDJ_SLACK/parser/LesBonsNumerosAPIParser.go    :82 +0x7e0
169 main.getLotteryResult(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
170         /home/monf/go/src/github.com/LaMonF/FDJ_SLACK/main.go:77 +0xc8
171 main.getResultAndPostToSlack(0x0, 0x0, 0x0)
172         /home/monf/go/src/github.com/LaMonF/FDJ_SLACK/main.go:58 +0x65
173 main.setUpCron.func1()
174         /home/monf/go/src/github.com/LaMonF/FDJ_SLACK/main.go:53 +0x32
175 github.com/robfig/cron.FuncJob.Run(0x7036e8)
176         /home/monf/go/src/github.com/robfig/cron/cron.go:92 +0x25
177 github.com/robfig/cron.(*Cron).runWithRecovery(0xc4200a4230, 0x725a60, 0x7036e8)
178         /home/monf/go/src/github.com/robfig/cron/cron.go:165 +0x57
179 created by github.com/robfig/cron.(*Cron).run
180         /home/monf/go/src/github.com/robfig/cron/cron.go:199 +0x744
LaMonF commented 5 years ago

First investigation :

if len(resultByLine) > 4 { // When results are not up to date len(result_line_list) == 4
            numberWinner = extractNumberWinner(resultByLine[11])
            winnerPrize = extractWinnerPrize(resultByLine[11])
            nextLotteryDate = extractNextLotteryDate(resultByLine[12])
            nextLotteryPrize = extractNextLotteryPrize(resultByLine[12])
        }

resultByLine[11] ==> index out of range