Use ExceptionDispatchInfo

pull/12940/head
gnattu 4 months ago
parent e9ee0ef1f5
commit bb30d26ffb

@ -7,6 +7,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Mime; using System.Net.Mime;
using System.Runtime.ExceptionServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsyncKeyedLock; using AsyncKeyedLock;
@ -258,7 +259,7 @@ namespace MediaBrowser.Providers.Manager
throw new ArgumentNullException(nameof(source)); throw new ArgumentNullException(nameof(source));
} }
Exception? saveException = null; ExceptionDispatchInfo? saveException = null;
try try
{ {
@ -267,7 +268,7 @@ namespace MediaBrowser.Providers.Manager
} }
catch (Exception ex) catch (Exception ex)
{ {
saveException = ex; saveException = ExceptionDispatchInfo.Capture(ex);
_logger.LogError(ex, "Unable to save image {Source}", source); _logger.LogError(ex, "Unable to save image {Source}", source);
} }
finally finally
@ -282,14 +283,11 @@ namespace MediaBrowser.Providers.Manager
} }
catch (Exception ex) catch (Exception ex)
{ {
saveException ??= ex; saveException ??= ExceptionDispatchInfo.Capture(ex);
} }
} }
if (saveException is not null) saveException?.Throw();
{
throw saveException;
}
} }
/// <inheritdoc/> /// <inheritdoc/>

Loading…
Cancel
Save