Clean up some catch statements

This commit is contained in:
Bond_009 2018-12-20 13:39:58 +01:00
parent ea4c914123
commit 79d18cf5a5
14 changed files with 56 additions and 63 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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.PlayTo
if (_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++;

View File

@ -101,9 +101,9 @@ namespace Emby.Drawing.ImageMagick
wand.SaveImage(tmpPath);
}
}
catch
catch (Exception ex)
{
//_logger.LogError(ex, "Error loading webp: ");
_logger.LogError(ex, "Error loading webp");
_webpAvailable = false;
}
}

View File

@ -646,16 +646,16 @@ namespace Emby.Drawing
var 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)

View File

@ -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 IsoMounter
if (!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 IsoMounter
Name
);
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);
}
}
#endregion

View File

@ -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;

View File

@ -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;
}

View File

@ -166,6 +166,7 @@ namespace Emby.Server.Implementations.EntryPoints
}
catch (Exception ex)
{
_logger.LogError(ex, "Error");
return;
}

View File

@ -89,7 +89,7 @@ namespace SharpCifs
{
Runtime.GetBytesForString(string.Empty, DefaultOemEncoding);
}
catch (Exception ex)
catch (Exception)
{
if (_log.Level >= 2)
{

View File

@ -153,7 +153,7 @@ namespace SharpCifs.Dcerpc
DcerpcMessage bind = new DcerpcBind(Binding, this);
Sendrecv(bind);
}
catch (IOException ioe)
catch (IOException)
{
State = 0;
throw;

View File

@ -130,7 +130,7 @@ namespace SharpCifs.Netbios
{
name = Runtime.GetStringForBytes(tmp, 0, length).Trim();
}
catch (Exception ex)
catch (Exception)
{
}

View File

@ -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)

View File

@ -192,7 +192,7 @@ namespace SharpCifs.Smb
catch (Exception e)
{
throw new SmbException(e.Message, e);
}
}
}
default: