diff options
| author | Bond_009 <bond.009@outlook.com> | 2018-12-20 13:39:58 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2018-12-30 22:44:39 +0100 |
| commit | 79d18cf5a5fde7594eb17247f920a54d8978a81c (patch) | |
| tree | 59343a16d7df98f59e305e63fa2f585d443a7ddd /Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs | |
| parent | ea4c914123ba8279b9d9fcf7d5318e11f7a3da4c (diff) | |
Clean up some catch statements
Diffstat (limited to 'Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs')
| -rw-r--r-- | Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs | 72 |
1 files changed, 30 insertions, 42 deletions
diff --git a/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs b/Emby.IsoMounting/IsoMounter/LinuxIsoManager.cs index e6986ddcb..faaed482a 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 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 |
