Always collect exceptions instead of swallowing them

This commit is contained in:
Hylke Bons 2018-03-10 19:09:48 +00:00
parent 5bf34b0db4
commit f308216bbc
4 changed files with 17 additions and 12 deletions

View file

@ -73,7 +73,8 @@ namespace SparkleShare {
else
UpdateLabelEvent ("✓ You are running the latest version");
} catch {
} catch (Exception e) {
Logger.LogInfo ("UI", "Failed to download " + uri , e);
UpdateLabelEvent ("Couldnt check for updates\t");
}
}

View file

@ -346,8 +346,8 @@ namespace SparkleShare {
Logger.LogInfo ("Controller", "Added preset for " + uri.Host);
}
} catch {
Logger.LogInfo ("Controller", "Failed adding preset for " + uri.Host);
} catch (Exception e) {
Logger.LogInfo ("Controller", "Failed adding preset for " + uri.Host, e);
}
}

View file

@ -19,6 +19,7 @@ using System;
using System.IO;
using Gtk;
using Sparkles;
namespace SparkleShare {
@ -35,7 +36,9 @@ namespace SparkleShare {
try {
return icon_theme.LoadIcon (name, size, IconLookupFlags.GenericFallback);
} catch {
} catch (Exception e) {
Logger.LogInfo ("UI", "Failed to load icon " + name + " of size " + size, e);
try {
return icon_theme.LoadIcon ("gtk-missing-image", size, IconLookupFlags.GenericFallback);

View file

@ -102,7 +102,8 @@ namespace Sparkles.Git {
string size = File.ReadAllText (file_path);
return double.Parse (size);
} catch {
} catch (Exception e) {
Logger.LogInfo ("Git", Name + " | Failed to parse " + file_path, e);
return 0;
}
}
@ -117,7 +118,8 @@ namespace Sparkles.Git {
string size = File.ReadAllText (file_path);
return double.Parse (size);
} catch {
} catch (Exception e) {
Logger.LogInfo ("Git", Name + " | Failed to parse " + file_path, e);
return 0;
}
}
@ -638,16 +640,15 @@ namespace Sparkles.Git {
try {
File.Move (local_file_path, target_file_path);
} catch {
Logger.LogInfo ("Git",
Name + " | Could not move \"" + local_file_path + "\" to \"" + target_file_path + "\"");
} catch (Exception e) {
string message = string.Format ("Failed to move \"{0}\" to \"{1}\"", local_file_path, target_file_path);
Logger.LogInfo ("Git", Name + " | " + message, e);
}
// ...and restore the most recent revision
git = new GitCommand (LocalPath, "checkout " + CurrentRevision + " \"" + path + "\"");
git.StartAndWaitForExit ();
if (target_file_path.StartsWith (LocalPath))
new Thread (() => OnFileActivity (null)).Start ();
}
@ -966,8 +967,8 @@ namespace Sparkles.Git {
File.WriteAllText (Path.Combine (path, ".empty"), "I'm a folder!");
File.SetAttributes (Path.Combine (path, ".empty"), FileAttributes.Hidden);
} catch {
Logger.LogInfo ("Git", Name + " | Failed adding empty folder " + path);
} catch (Exception e) {
Logger.LogInfo ("Git", Name + " | Failed adding empty folder " + path, e);
}
}
}