The Free Software Media System - Server Backend & API
Clean up some catch statements
Bond_00979d18cf5a5fd
diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.csindex 6de35b8426..7af48ae17e 100644--- a/Emby.Dlna/Didl/DidlBuilder.cs+++ b/Emby.Dlna/Didl/DidlBuilder.cs@@ -1070,9 +1070,9 @@ namespace Emby.Dlna.Didl{tag = _imageProcessor.GetImageCacheTag(item, type);}- catch+ catch (Exception ex){-+ _logger.LogError(ex, "Error getting image cache tag");}int? width = imageInfo.Width;diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.csindex eae4f32716..48a33757be 100644--- a/Emby.Dlna/DlnaManager.cs+++ b/Emby.Dlna/DlnaManager.cs@@ -198,7 +198,7 @@ namespace Emby.Dlna}catch (ArgumentException ex){- _logger.LogError(ex, "Error evaluating regex pattern {0}", pattern);+ _logger.LogError(ex, "Error evaluating regex pattern {Pattern}", pattern);return false;}}@@ -324,7 +324,7 @@ namespace Emby.Dlna}catch (Exception ex){- _logger.LogError(ex, "Error parsing profile file: {0}", path);+ _logger.LogError(ex, "Error parsing profile file: {Path}", path);return null;}diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.csindex a1df90ec03..13bed6b2fd 100644--- a/Emby.Dlna/PlayTo/Device.cs+++ b/Emby.Dlna/PlayTo/Device.cs@@ -140,7 +140,7 @@ namespace Emby.Dlna.PlayTo}catch (Exception ex){- _logger.LogError(ex, "Error updating device volume info for {0}", Properties.Name);+ _logger.LogError(ex, "Error updating device volume info for {DeviceName}", Properties.Name);}}@@ -507,7 +507,7 @@ namespace Emby.Dlna.PlayToif (_disposed)return;- //_logger.LogError(ex, "Error updating device info for {0}", Properties.Name);+ _logger.LogError(ex, "Error updating device info for {DeviceName}", Properties.Name);_connectFailureCount++;diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.csindex 6aac77cf4b..5de8ac383e 100644--- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs+++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs@@ -101,9 +101,9 @@ namespace Emby.Drawing.ImageMagickwand.SaveImage(tmpPath);}}- catch+ catch (Exception ex){- //_logger.LogError(ex, "Error loading webp: ");+ _logger.LogError(ex, "Error loading webp");_webpAvailable = false;}}diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.csindex c417f37854..6a67be56d1 100644--- a/Emby.Drawing/ImageProcessor.cs+++ b/Emby.Drawing/ImageProcessor.cs@@ -646,16 +646,16 @@ namespace Emby.Drawingvar cacheGuid = GetImageCacheTag(item, image, enhancers);// Enhance if we have enhancers- var ehnancedImageInfo = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid, cancellationToken).ConfigureAwait(false);+ var enhancedImageInfo = await GetEnhancedImageInternal(originalImagePath, item, imageType, imageIndex, enhancers, cacheGuid, cancellationToken).ConfigureAwait(false);- var ehnancedImagePath = ehnancedImageInfo.Item1;+ var enhancedImagePath = enhancedImageInfo.Item1;// If the path changed update dateModified- if (!string.Equals(ehnancedImagePath, originalImagePath, StringComparison.OrdinalIgnoreCase))+ if (!string.Equals(enhancedImagePath, originalImagePath, StringComparison.OrdinalIgnoreCase)){- var treatmentRequiresTransparency = ehnancedImageInfo.Item2;+ var treatmentRequiresTransparency = enhancedImageInfo.Item2;- return new ValueTuple<string, DateTime, bool>(ehnancedImagePath, _fileSystem.GetLastWriteTimeUtc(ehnancedImagePath), treatmentRequiresTransparency);+ return new ValueTuple<string, DateTime, bool>(enhancedImagePath, _fileSystem.GetLastWriteTimeUtc(enhancedImagePath), treatmentRequiresTransparency);}}catch (Exception ex)diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.csindex e6986ddcbe..faaed482a0 100644--- a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs+++ b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs@@ -260,35 +260,29 @@ namespace IsoMounter});- try {-+ try+ {process.Start();//StreamReader outputReader = process.StandardOutput.;//StreamReader errorReader = process.StandardError;_logger.LogDebug(- "[{0}] Standard output from process is [{1}].",+ "[{Name}] Standard output from process is [{Error}].",Name,process.StandardOutput.ReadToEnd());_logger.LogDebug(- "[{0}] Standard error from process is [{1}].",+ "[{Name}] Standard error from process is [{Error}].",Name,process.StandardError.ReadToEnd());-- } catch (Exception ex) {-+ }+ catch (Exception ex)+ {processFailed = true;-- _logger.LogDebug(- "[{0}] Unhandled exception executing command, exception is [{1}].",- Name,- ex.Message- );-+ _logger.LogDebug(ex, "[{Name}] Unhandled exception executing command.", Name);}if (!processFailed && process.ExitCode == 0) {@@ -309,13 +303,13 @@ namespace IsoMounterif (!string.IsNullOrEmpty(isoPath)) {_logger.LogInformation(- "[{0}] Attempting to mount [{1}].",+ "[{Name}] Attempting to mount [{Path}].",Name,isoPath);_logger.LogDebug(- "[{0}] ISO will be mounted at [{1}].",+ "[{Name}] ISO will be mounted at [{Path}].",Name,mountPoint);@@ -326,11 +320,16 @@ namespace IsoMounter}- try {+ try+ {FileSystem.CreateDirectory(mountPoint);- } catch (UnauthorizedAccessException) {+ }+ catch (UnauthorizedAccessException)+ {throw new IOException("Unable to create mount point(Permission denied) for " + isoPath);- } catch (Exception) {+ }+ catch (Exception)+ {throw new IOException("Unable to create mount point for " + isoPath);}@@ -365,18 +364,13 @@ namespace IsoMounterName);- try {-+ try+ {FileSystem.DeleteDirectory(mountPoint, false);-- } catch (Exception ex) {-- _logger.LogInformation(- "[{0}] Unhandled exception removing mount point, exception is [{1}].",- Name,- ex.Message- );-+ }+ catch (Exception ex)+ {+ _logger.LogInformation(ex, "[{Name}] Unhandled exception removing mount point.", Name);}mountedISO = null;@@ -439,20 +433,14 @@ namespace IsoMounter}- try {-+ try+ {FileSystem.DeleteDirectory(mount.MountedPath, false);-- } catch (Exception ex) {-- _logger.LogInformation(- "[{0}] Unhandled exception removing mount point, exception is [{1}].",- Name,- ex.Message- );-}-+ catch (Exception ex)+ {+ _logger.LogInformation(ex, "[{Name}] Unhandled exception removing mount point.", Name);+ }}#endregiondiff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 888635c9d8..d4b740d712 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -2214,7 +2214,7 @@ namespace Emby.Server.Implementations}catch (Exception ex){- Logger.LogDebug("Ping test result to {0}. Success: {1} {2}", apiUrl, false, ex.Message);+ Logger.LogDebug(ex, "Ping test result to {0}. Success: {1}", apiUrl, false);_validAddressResults.AddOrUpdate(apiUrl, false, (k, v) => false);return false;diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.csindex e8d06ec002..7871d3fb3b 100644--- a/Emby.Server.Implementations/Dto/DtoService.cs+++ b/Emby.Server.Implementations/Dto/DtoService.cs@@ -619,7 +619,7 @@ namespace Emby.Server.Implementations.Dto}catch (Exception ex){- _logger.LogError(ex, "Error getting person {0}", c);+ _logger.LogError(ex, "Error getting person {Name}", c);return null;}diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.csindex a95e21e1c5..6cd867921f 100644--- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs+++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs@@ -166,6 +166,7 @@ namespace Emby.Server.Implementations.EntryPoints}catch (Exception ex){+ _logger.LogError(ex, "Error");return;}diff --git a/Emby.Server.Implementations/IO/SharpCifs/Config.cs b/Emby.Server.Implementations/IO/SharpCifs/Config.csindex 3fd0e5bd64..324a9c494d 100644--- a/Emby.Server.Implementations/IO/SharpCifs/Config.cs+++ b/Emby.Server.Implementations/IO/SharpCifs/Config.cs@@ -89,7 +89,7 @@ namespace SharpCifs{Runtime.GetBytesForString(string.Empty, DefaultOemEncoding);}- catch (Exception ex)+ catch (Exception){if (_log.Level >= 2){diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.csindex 786b0ac122..e82af2b0cf 100644--- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs+++ b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs@@ -153,7 +153,7 @@ namespace SharpCifs.DcerpcDcerpcMessage bind = new DcerpcBind(Binding, this);Sendrecv(bind);}- catch (IOException ioe)+ catch (IOException){State = 0;throw;diff --git a/Emby.Server.Implementations/IO/SharpCifs/Netbios/Name.cs b/Emby.Server.Implementations/IO/SharpCifs/Netbios/Name.csindex 6c37d57a46..15ae494bea 100644--- a/Emby.Server.Implementations/IO/SharpCifs/Netbios/Name.cs+++ b/Emby.Server.Implementations/IO/SharpCifs/Netbios/Name.cs@@ -130,7 +130,7 @@ namespace SharpCifs.Netbios{name = Runtime.GetStringForBytes(tmp, 0, length).Trim();}- catch (Exception ex)+ catch (Exception){}diff --git a/Emby.Server.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs b/Emby.Server.Implementations/IO/SharpCifs/Netbios/NameServiceClient.csindex 01700e64a5..0d7840a643 100644--- a/Emby.Server.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs+++ b/Emby.Server.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs@@ -117,8 +117,9 @@ namespace SharpCifs.Netbios{Baddr = Config.GetInetAddress("jcifs.netbios.baddr", Extensions.GetAddressByName("255.255.255.255"));}- catch (Exception ex)+ catch (Exception){+}_sndBuf = new byte[SndBufSize];@@ -302,7 +303,10 @@ namespace SharpCifs.Netbios}}- catch (TimeoutException) { }+ catch (TimeoutException)+ {++ }catch (Exception ex){if (_log.Level > 2)diff --git a/Emby.Server.Implementations/IO/SharpCifs/Smb/NtlmContext.cs b/Emby.Server.Implementations/IO/SharpCifs/Smb/NtlmContext.csindex 44266f9740..aa52ee1db8 100644--- a/Emby.Server.Implementations/IO/SharpCifs/Smb/NtlmContext.cs+++ b/Emby.Server.Implementations/IO/SharpCifs/Smb/NtlmContext.cs@@ -192,7 +192,7 @@ namespace SharpCifs.Smbcatch (Exception e){throw new SmbException(e.Message, e);- }+ }}default: