Added ExceptionConverter in JsonSerializerSettings at DocumentClient (#472)

This commit is contained in:
cvijayak 2020-11-25 01:14:28 +05:30 committed by GitHub
parent 20e24fc572
commit 7ceb3106aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -1,14 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
namespace Elsa.Serialization.Converters
{
public class ExceptionConverter : JsonConverter<Exception>
{
public override void WriteJson(JsonWriter writer, Exception value, JsonSerializer serializer)
{
throw new NotImplementedException("Unnecessary because CanRead is false. The type will skip the converter.");
@ -22,7 +19,6 @@ namespace Elsa.Serialization.Converters
var jObject = JObject.Load(reader);
var ex = System.Text.Json.JsonSerializer.Deserialize<Exception>(jObject.ToString());
return ex;
}
}
}

View file

@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Elsa.Serialization.Converters;
namespace Elsa.Persistence.DocumentDb
{
@ -36,6 +37,8 @@ namespace Elsa.Persistence.DocumentDb
}
}.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
settings.Converters.Add(new ExceptionConverter());
var connectionPolicy = ConnectionPolicy.Default;
connectionPolicy.ConnectionMode = this.options.ConnectionMode;
connectionPolicy.ConnectionProtocol = this.options.ConnectionProtocol;