aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2019-11-06 09:46:31 -0500
committerAndrew Mahone <andrew.mahone@gmail.com>2019-11-06 09:46:31 -0500
commit4f3b8831552db1d376198384cfe42894883286dd (patch)
tree707e81a8d8a45246c20597df5e8a539b20f9a7e8
parent79bbf09ecba6d3c2ddb0955bdbd51164a6c7a236 (diff)
Clean up handling of missing source/attachment in AttachmentExtractor.
-rw-r--r--MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs20
1 files changed, 6 insertions, 14 deletions
diff --git a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
index 0c8d9ae9c..bda5c2f37 100644
--- a/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
+++ b/MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs
@@ -66,23 +66,15 @@ namespace MediaBrowser.MediaEncoding.Attachments
}
var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
- MediaSourceInfo mediaSource;
- MediaAttachment mediaAttachment;
- try
- {
- mediaSource = mediaSources
- .First(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
- }
- catch (Exception ex) when (ex is ArgumentNullException || ex is InvalidOperationException)
+ var mediaSource = mediaSources
+ .FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
+ if (mediaSource == null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} not found");
}
- try
- {
- mediaAttachment = mediaSource.MediaAttachments
- .First(i => i.Index == attachmentStreamIndex);
- }
- catch (Exception ex) when (ex is ArgumentNullException || ex is InvalidOperationException)
+ var mediaAttachment = mediaSource.MediaAttachments
+ .FirstOrDefault(i => i.Index == attachmentStreamIndex);
+ if (mediaAttachment == null)
{
throw new ResourceNotFoundException($"MediaSource {mediaSourceId} has no attachment with stream index {attachmentStreamIndex}");
}