Rename to SerializableException
MODIFY
WalletWasabi.Gui/CrashReport/CrashReporter.cs
WalletWasabi.Gui/CrashReport/CrashReporter.cs
@@ -3,10 +3,10 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
-using WalletWasabi.Gui.CrashReport.Models;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Microservices;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.CrashReport
{
@@ -18,7 +18,7 @@ namespace WalletWasabi.Gui.CrashReport
public string ExceptionString { get; private set; } = null;
public bool IsReport => ExceptionString is { };
- public SerializedException SerializedException { get; private set; }
+ public SerializableException SerializedException { get; private set; }
public void InvokeCrashReport()
{
@@ -39,11 +39,11 @@ namespace WalletWasabi.Gui.CrashReport
return;
}
- public void SetException(string exceptionString, int attempts)
+ public void SetException(string base64ExceptionString, int attempts)
{
Attempts = attempts;
- ExceptionString = exceptionString;
- SerializedException = SerializedException.ToSerializedException(ExceptionString);
+ ExceptionString = base64ExceptionString;
+ SerializedException = SerializableException.FromBase64String(ExceptionString);
}
/// <summary>
@@ -51,7 +51,7 @@ namespace WalletWasabi.Gui.CrashReport
/// </summary>
public void SetException(Exception ex)
{
- SetException(SerializedException.ToCommandLineString(ex), 1);
+ SetException(SerializableException.ToBase64String(ex.ToSerializableException()), 1);
}
public override string ToString()

MODIFY
WalletWasabi.Gui/CrashReport/Helpers/StartCrashReporterHelper.cs
WalletWasabi.Gui/CrashReport/Helpers/StartCrashReporterHelper.cs
@@ -4,7 +4,7 @@ using System;
using WalletWasabi.Logging;
using Newtonsoft.Json;
using System.Diagnostics;
-using WalletWasabi.Gui.CrashReport.Models;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.CrashReport.Helpers
{
@@ -18,7 +18,7 @@ namespace WalletWasabi.Gui.CrashReport.Helpers
Environment.Exit(-1);
}
- var jsonException = JsonConvert.SerializeObject(new SerializedException(e), Formatting.None)
+ var jsonException = JsonConvert.SerializeObject(new SerializableException(e), Formatting.None)
.Replace("\'", "\\X0009")
.Replace("\"", "\\X0022")
.Replace("\n", "\\X000A")

MODIFY
WalletWasabi/Extensions/ExceptionExtensions.cs
WalletWasabi/Extensions/ExceptionExtensions.cs
@@ -3,6 +3,7 @@ using System.Net.Http;
using System.Text;
using WalletWasabi.Helpers;
using WalletWasabi.Hwi.Exceptions;
+using WalletWasabi.Models;
namespace System
{
@@ -66,5 +67,10 @@ namespace System
return ex.ToTypeMessageString();
}
}
+
+ public static SerializableException ToSerializableException(this Exception ex)
+ {
+ return new SerializableException(ex);
+ }
}
}

RENAME
WalletWasabi.Gui/CrashReport/Models/SerializedException.cs
WalletWasabi/Models/SerializableException.cs
@@ -2,20 +2,20 @@ using Newtonsoft.Json;
using System;
using System.Text;
-namespace WalletWasabi.Gui.CrashReport.Models
+namespace WalletWasabi.Models
{
[JsonObject(MemberSerialization.OptIn)]
- public class SerializedException
+ public class SerializableException
{
- public SerializedException()
+ public SerializableException()
{
}
- public SerializedException(Exception ex)
+ public SerializableException(Exception ex)
{
if (ex.InnerException != null)
{
- InnerException = new SerializedException(ex.InnerException);
+ InnerException = new SerializableException(ex.InnerException);
}
ExceptionType = ex.GetType().FullName;
@@ -34,17 +34,17 @@ namespace WalletWasabi.Gui.CrashReport.Models
public string StackTrace { get; set; }
[JsonProperty(PropertyName = "InnerException")]
- public SerializedException InnerException { get; set; }
+ public SerializableException InnerException { get; set; }
- public static string ToCommandLineString(Exception exception)
+ public static string ToBase64String(SerializableException exception)
{
- return Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new SerializedException(exception))));
+ return Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(exception)));
}
- public static SerializedException ToSerializedException(string serializedException)
+ public static SerializableException FromBase64String(string base64String)
{
- var json = Encoding.UTF8.GetString(Convert.FromBase64String(serializedException));
- var se = JsonConvert.DeserializeObject<SerializedException>(json);
+ var json = Encoding.UTF8.GetString(Convert.FromBase64String(base64String));
+ var se = JsonConvert.DeserializeObject<SerializableException>(json);
return se;
}

Rename to SerializableException