mirror of
https://github.com/sphildreth/roadie
synced 2024-11-10 06:44:12 +00:00
28 lines
No EOL
648 B
C#
28 lines
No EOL
648 B
C#
using System;
|
|
using System.Text.Json;
|
|
|
|
namespace Roadie.Library.Extensions
|
|
{
|
|
public static class ExceptionExt
|
|
{
|
|
public static string Serialize(this Exception input)
|
|
{
|
|
if (input == null)
|
|
{
|
|
return null;
|
|
}
|
|
try
|
|
{
|
|
return JsonSerializer.Serialize(input, new JsonSerializerOptions
|
|
{
|
|
IgnoreNullValues = true,
|
|
WriteIndented = true
|
|
});
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return input?.ToString();
|
|
}
|
|
}
|
|
}
|
|
} |