mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Merge pull request #163 from wabbajack-tools/small-fixes
Change exception printing, and unset read-only during move.
This commit is contained in:
commit
adcd991b0e
@ -497,24 +497,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public static string ExceptionToString(this Exception ex)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
while (ex != null)
|
||||
{
|
||||
sb.AppendLine(ex.Message);
|
||||
var st = new StackTrace(ex, true);
|
||||
foreach (var frame in st.GetFrames())
|
||||
sb.AppendLine(
|
||||
$"{frame.GetFileName()}:{frame.GetMethod().Name}:{frame.GetFileLineNumber()}:{frame.GetFileColumnNumber()}");
|
||||
ex = ex.InnerException;
|
||||
}
|
||||
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void CrashDump(Exception e)
|
||||
{
|
||||
File.WriteAllText($"{DateTime.Now.ToString("yyyyMMddTHHmmss_crash_log.txt")}", ExceptionToString(e));
|
||||
return ex.ToString();
|
||||
}
|
||||
|
||||
public static IEnumerable<T> DistinctBy<T, V>(this IEnumerable<T> vs, Func<T, V> select)
|
||||
|
@ -400,7 +400,21 @@ namespace Wabbajack.Lib
|
||||
void CopyFile(string from, string to, bool use_move)
|
||||
{
|
||||
if (File.Exists(to))
|
||||
{
|
||||
var fi = new FileInfo(to);
|
||||
if (fi.IsReadOnly)
|
||||
fi.IsReadOnly = false;
|
||||
File.Delete(to);
|
||||
}
|
||||
|
||||
if (File.Exists(from))
|
||||
{
|
||||
var fi = new FileInfo(from);
|
||||
if (fi.IsReadOnly)
|
||||
fi.IsReadOnly = false;
|
||||
}
|
||||
|
||||
|
||||
if (use_move)
|
||||
File.Move(from, to);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user