public async Task <IActionResult> Get(ulong id) { try { return(Json(await _fetcher.FetchAsync(id))); } catch (ContactNotFoundException <DiscordContact> ) { return(NotFound()); } }
private FetchedFile FetchUrl(string url) { var fetchedFile = mFetcher.FetchAsync(url).GetAwaiter().GetResult(); if (fetchedFile == null) { // Fetched nothing // Push back this url mUrlFrontier.PushBackUrl(url, 0, true); return(null); } return(fetchedFile); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { try { _logger.LogInformation("Fetching..."); await _exchangeFetcher.FetchAsync(stoppingToken); } catch (OperationCanceledException) when(stoppingToken.IsCancellationRequested) { _logger.LogInformation("Execution is canceled"); } catch (Exception e) { _logger.LogError(e, "Unknown error occurred"); } } }