예제 #1
0
        private async Task <IndexerResult> QueryIndexer(
            IIndexer indexer
            , Query query
            , CancellationToken token
            )
        {
            var indexerResult = new IndexerResult {
                Indexer = indexer.Tag
            };

            try
            {
                var result = await indexer.Query(query, token);

                indexerResult.Torrents = result?.Where(t => t != null)
                                         ?? new Torrent[0];
            }
            catch (TaskCanceledException exception)
            {
                _logger.LogError(
                    $"{indexer} timed out during query."
                    , exception
                    );
            }
            catch (Exception exception)
            {
                _logger.LogError(
                    $"{indexer} threw an exception during execution."
                    , exception
                    );
            }

            return(indexerResult);
        }