Class ExceptionConverter
- Assembly
- Cuemon.Extensions.Text.Json.dll
Provides an Exception converter that can be configured like the Newtonsoft.JSON equivalent.
public class ExceptionConverter : JsonConverter<Exception>
- Inheritance
-
ExceptionConverter
- Inherited Members
- Extension Methods
Constructors
ExceptionConverter(Boolean, Boolean)
Initializes a new instance of the ExceptionConverter class.
public ExceptionConverter(bool includeStackTrace = false, bool includeData = false)
Parameters
includeStackTrace
BooleanA value that indicates if the stack of an exception is included in the converted result.
includeData
BooleanA value that indicates if the data of an exception is included in the converted result.
Properties
IncludeData
Gets a value indicating whether the data of an exception is included in the converted result.
public bool IncludeData { get; }
Property Value
- Boolean
true
if the data of an exception is included in the converted result; otherwise,false
.
IncludeStackTrace
Gets a value indicating whether the stack of an exception is included in the converted result.
public bool IncludeStackTrace { get; }
Property Value
- Boolean
true
if the stack of an exception is included in the converted result; otherwise,false
.
Methods
CanConvert(Type)
Determines whether this instance can convert the specified object type.
public override bool CanConvert(Type typeToConvert)
Parameters
typeToConvert
TypeType of the object.
Returns
- Boolean
true
if this instance can convert the specified object type; otherwise,false
.
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type Exception.
public override Exception Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
reader
Utf8JsonReaderThe Utf8JsonReader to read from.
typeToConvert
TypeThe Type being converted.
options
JsonSerializerOptionsThe JsonSerializerOptions being used.
Returns
- Exception
The value that was converted.
Write(Utf8JsonWriter, Exception, JsonSerializerOptions)
Writes the value
as JSON.
public override void Write(Utf8JsonWriter writer, Exception value, JsonSerializerOptions options)
Parameters
writer
Utf8JsonWriterThe Utf8JsonWriter to write to.
value
ExceptionThe value to convert.
options
JsonSerializerOptionsThe JsonSerializerOptions being used.