Skip to content

Commit

Permalink
fix: geoip lookup should be try-caught
Browse files Browse the repository at this point in the history
Signed-off-by: Arnav Gupta <championswimmer@gmail.com>
  • Loading branch information
championswimmer committed Feb 24, 2024
1 parent 106fd92 commit dddbba9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/controllers/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ func (c *EventsController) LogRedirectAsync(redirData *EventRedirectData) {
IPAddress: redirData.IPAddress,
Referer: redirData.Referer,
}
geoIpData, err := clientinfo.GetGeoIpDataFromIP(c.geoipDB, redirData.IPAddress)
if err != nil {
applogger.Warn("LogRedirectAsync: failed to get geoip data: ", err)
} else {
lo.TryCatchWithErrorValue(func() error {
geoIpData, err := clientinfo.GetGeoIpDataFromIP(c.geoipDB, redirData.IPAddress)
event.GeoIpData = *geoIpData
}
return err
}, func(e any) {
applogger.Warn("LogRedirectAsync: failed to get geoip data: ", e)
})

lo.Try(func() error {
tx := c.eventDb.Create(event)
Expand Down

0 comments on commit dddbba9

Please sign in to comment.