Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
-Added verification if category exist in map
  • Loading branch information
Veronika Solovei committed May 14, 2019
1 parent be41c4b commit 925cc9f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions stored_requests/backends/http_fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func (fetcher *HttpFetcher) FetchCategories(ctx context.Context, primaryAdServer
}

if data, ok := fetcher.Categories[dataName]; ok {
return data[iabCategory].Id, nil
if val, ok := data[iabCategory]; ok {
return val.Id, nil
} else {
return "", fmt.Errorf("Unable to find category mapping for adserver: '%s', publisherId: '%s'", primaryAdServer, publisherId)
}
}

httpReq, err := http.NewRequest("GET", url, nil)
Expand All @@ -120,9 +124,11 @@ func (fetcher *HttpFetcher) FetchCategories(ctx context.Context, primaryAdServer
}
fetcher.Categories[dataName] = tmp

resultCategory := tmp[iabCategory].Id

return resultCategory, nil
if val, ok := tmp[iabCategory]; ok {
return val.Id, nil
} else {
return "", fmt.Errorf("Unable to find category mapping for adserver: '%s', publisherId: '%s'", primaryAdServer, publisherId)
}
}

func buildRequest(endpoint string, requestIDs []string, impIDs []string) (*http.Request, error) {
Expand Down

0 comments on commit 925cc9f

Please sign in to comment.