danielgross / whatsapp-gpt

MIT License
3.07k stars 598 forks source link

go/connector: catch non-2XX responses e.g. a 502 or 403 #14

Open odeke-em opened 1 year ago

odeke-em commented 1 year ago

Currently if the HTTP call to Whatsapp fails with a non-2XX code e.g. 502 or 403, this condition won't be caught and that data will just be serialized to the database and sent to GPT :-( as per https://github.com/danielgross/whatsapp-gpt/blob/d12693276e1e88d5d335276aa42bcfd849d56023/main.go#L47-L61

We should catch this problem by doing this

if resp.StatusCode/100 != 2 { // Non-2XX HTTP response