diff options
| author | horus_arch | 2018-02-17 13:51:35 +0100 |
|---|---|---|
| committer | horus_arch | 2018-02-17 13:51:35 +0100 |
| commit | bcdea2f8e95f5305625a773223829478c8c13bed (patch) | |
| tree | efac40b03131b4f9e43de848920695ee785a0a3f /crawler/shop_whiskyzone.go | |
| parent | 9ebf51364773dae6db4c0c47d77710c9f1a37b51 (diff) | |
| download | alkobote-bcdea2f8e95f5305625a773223829478c8c13bed.tar.gz | |
Introduces context on errors. (crawler)
Diffstat (limited to 'crawler/shop_whiskyzone.go')
| -rw-r--r-- | crawler/shop_whiskyzone.go | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/crawler/shop_whiskyzone.go b/crawler/shop_whiskyzone.go index 8d86b8a..f01e93f 100644 --- a/crawler/shop_whiskyzone.go +++ b/crawler/shop_whiskyzone.go @@ -6,7 +6,7 @@ import ( "github.com/gocolly/colly" ) -func ScrapeWhiskyzone(shop Shop) []Angebot { +func (app *App) ScrapeWhiskyzone(shop Shop) []Angebot { Shop_url := "https://www.whiskyzone.de/widgets/emotion/index/emotionId/248/controllerName/listing" @@ -45,23 +45,33 @@ func ScrapeWhiskyzone(shop Shop) []Angebot { var err error W.Discounted_price, err = convert_price(e.Request.Ctx.Get("discounted_price")) if err != nil { - Fatal(err, "Whiskyzone: Convert discounted price failed") + W.error_msg = err.Error() + W.error_ctx = e.Request.Ctx.Get("discounted_price") + WarnOffer(W, "Whiskyzone: Convert discounted price failed") + return } W.Original_price, err = convert_price(e.Request.Ctx.Get("original_price")) if err != nil { - Fatal(err, "Whiskyzone: Convert original price failed") + W.error_msg = err.Error() + W.error_ctx = e.Request.Ctx.Get("original_price") + WarnOffer(W, "Whiskyzone: Convert original price failed") + return } - W.Volume = get_volume(e) - W.Abv = get_abv(e) - + var ctx string + W.Volume, ctx = get_volume(e) if W.Volume == 0 { - DebugOffer(W, "Whiskyzone: Volume is zero") + W.error_msg = "Whiskyzone: Volume is zero" + W.error_ctx = ctx + WarnOffer(W, "Whiskyzone: Volume is zero") return } + W.Abv, ctx = get_abv(e) if W.Abv == 0 { - DebugOffer(W, "Whiskyzone: Abv is zero") + W.error_msg = "Whiskyzone: Abv is zero" + W.error_ctx = ctx + WarnOffer(W, "Whiskyzone: Abv is zero") return } @@ -69,7 +79,13 @@ func ScrapeWhiskyzone(shop Shop) []Angebot { if base_price == "same_as_discounted_price" { W.Base_price = W.Discounted_price } else { - W.Base_price = get_base_price(e) + W.Base_price, err = get_base_price(e) + if err != nil { + W.error_msg = err.Error() + W.error_ctx = base_price + WarnOffer(W, "Whiskyzone: Extracting base price failed") + return + } } W.Website = e.Request.Ctx.Get("website") |
