TShock/TShockAPI/Extensions/ExceptionExt.cs
White b3a2b24daa Updated the Stat Tracker to use System.Net.Http types.
Very similar to the previous Update Manager changes. The stat tracker now uses asynchronous threaded calls and manages exceptions better
2017-03-06 21:35:14 +10:30

27 lines
626 B
C#

using System;
namespace TShockAPI.Extensions
{
/// <summary>
/// Extensions for Exceptions
/// </summary>
public static class ExceptionExt
{
/// <summary>
/// Builds a formatted string containing the messages of the given exception, and any inner exceptions it contains
/// </summary>
/// <param name="ex"></param>
/// <returns></returns>
public static string BuildExceptionString(this Exception ex)
{
string msg = ex.Message;
Exception inner = ex.InnerException;
while (inner != null)
{
msg += $"\r\n\t-> {inner.Message}";
inner = inner.InnerException;
}
return msg;
}
}
}