Example #1
0
 public async Task <IActionResult> Get(ulong id)
 {
     try
     {
         return(Json(await _fetcher.FetchAsync(id)));
     }
     catch (ContactNotFoundException <DiscordContact> )
     {
         return(NotFound());
     }
 }
Example #2
0
        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);
        }
Example #3
0
        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");
                }
            }
        }