Log first change exception

This commit is contained in:
bao-qian
2016-05-15 17:03:06 +01:00
parent 87497d2d09
commit cf9c41f437
20 changed files with 92 additions and 71 deletions

View File

@@ -63,7 +63,7 @@ namespace Wox.Infrastructure.Image
}
catch (System.Exception e)
{
Log.Error(e);
Log.Exception(e);
return ImageSources[ErrorIcon];
}
}
@@ -94,7 +94,7 @@ namespace Wox.Infrastructure.Image
}
catch (System.Exception e)
{
Log.Error(e);
Log.Exception(e);
return ImageSources[ErrorIcon];
}
}

View File

@@ -35,19 +35,29 @@ namespace Wox.Infrastructure.Logger
var type = $"{method.DeclaringType.NonNull().FullName}.{method.Name}";
return type;
}
public static void Error(System.Exception e)
public static void Error(string msg)
{
var type = CallerType();
var logger = LogManager.GetLogger(type);
System.Diagnostics.Debug.WriteLine($"ERROR: {msg}");
logger.Error(msg);
}
public static void Exception(System.Exception e)
{
#if DEBUG
throw e;
#else
while (e.InnerException != null)
var type = CallerType();
var logger = LogManager.GetLogger(type);
do
{
logger.Error(e.Message);
logger.Error(e.StackTrace);
logger.Error($"\n{e.StackTrace}");
e = e.InnerException;
}
} while (e != null);
#endif
}

View File

@@ -63,12 +63,12 @@ namespace Wox.Infrastructure.Storage
}
catch (SerializationException e)
{
Log.Error(e);
Log.Exception(e);
LoadDefault();
}
catch (InvalidCastException e)
{
Log.Error(e);
Log.Exception(e);
LoadDefault();
}
finally
@@ -114,7 +114,7 @@ namespace Wox.Infrastructure.Storage
}
catch (SerializationException e)
{
Log.Error(e);
Log.Exception(e);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace Wox.Infrastructure.Storage
catch (JsonSerializationException e)
{
LoadDefault();
Log.Error(e);
Log.Exception(e);
}
}