Files
speckle-sharp-sdk/Speckle.Sdk.Testing/Framework/ExceptionScrubber.cs
T
Adam Hathcock 3aa993cecb Add cancellation tests (#218)
* Don't log cancelling

* redo exception handling for receive

* remove null test case

* clean up with Id/Json and more cancels

* Change the exception stacks

* fix serialization test

* make a custom scrubber for internalized exceptions

* clean up

* fix namespaces again :(

* adjust the scrubber

* try to make tests more predictable

* rework exceptions again

* strip out compile files used

* formatting

* custom exception validation

* fix init

* Move serialization to own class

* save serialize test

* add deep clean

* add cancellation test on save to cache

* cancellation tests

* format

* do DI correctly

* receive cancel works
2025-01-30 13:42:15 +00:00

25 lines
576 B
C#

using Argon;
namespace Speckle.Sdk.Testing.Framework;
public class ExceptionScrubber : WriteOnlyJsonConverter<Exception>
{
public ExceptionScrubber() { }
public override void Write(VerifyJsonWriter writer, Exception value)
{
if (value.StackTrace != null)
{
var ex = new JObject
{
["Type"] = value.GetType().FullName,
["Message"] = value.Message,
["Source"] = value.Source?.Trim(),
};
writer.WriteRawValue(ex.ToString(Formatting.Indented));
return;
}
base.Write(writer, value.ToString());
}
}