notify me on http errors
This commit is contained in:
parent
540505e4bd
commit
8c734dd6f2
2 changed files with 9 additions and 4 deletions
|
@ -53,6 +53,12 @@ func NewBot(config *config.Config, db *db.Db, api *osuapi.Osuapi) (bot *Bot, err
|
|||
return
|
||||
}
|
||||
|
||||
func (bot *Bot) NotifyError(format string, args ...interface{}) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
channel, _ := bot.UserChannelCreate("100443064228646912")
|
||||
bot.ChannelMessageSend(channel.ID, msg)
|
||||
}
|
||||
|
||||
func (bot *Bot) errWrap(fn interface{}) interface{} {
|
||||
val := reflect.ValueOf(fn)
|
||||
origType := reflect.TypeOf(fn)
|
||||
|
@ -66,10 +72,7 @@ func (bot *Bot) errWrap(fn interface{}) interface{} {
|
|||
if len(res) > 0 && !res[0].IsNil() {
|
||||
err := res[0].Interface().(error)
|
||||
if err != nil {
|
||||
msg := fmt.Sprintf("error: %s", err)
|
||||
channel, _ := bot.UserChannelCreate("100443064228646912")
|
||||
id, _ := bot.ChannelMessageSend(channel.ID, msg)
|
||||
log.Println(id, msg)
|
||||
bot.NotifyError("error: %s", err)
|
||||
}
|
||||
}
|
||||
return []reflect.Value{}
|
||||
|
|
|
@ -20,6 +20,8 @@ func (s *Scraper) scrapePendingMaps() {
|
|||
pendingSets, err := s.api.SearchBeatmaps("pending")
|
||||
if err != nil {
|
||||
log.Println("error fetching pending sets", err)
|
||||
s.bot.NotifyError("failed to fetch pending sets", err)
|
||||
return
|
||||
}
|
||||
|
||||
allNewMaps := make(map[int][]osuapi.Beatmapset, 0)
|
||||
|
|
Loading…
Reference in a new issue