RoboZhando/Extensions/EmbedExtensions.cs
/// <summary>
/// Turns the exception into a embeded format.
/// </summary>
/// <param name="exception"></param>
/// <param name="showStackTrace"></param>
/// <returns></returns>
Turns the exception into a embeded format.
Turns the exception into a embeded format .
public static DiscordEmbedBuilder ToEmbed(this Exception exception, bool showStackTrace = true)
        {
            DiscordEmbedBuilder builder = new DiscordEmbedBuilder();
            builder.Color = ErrorColour;
            if (exception is AggregateException)
            {
                AggregateException aggregate = exception as AggregateException;
                builder.Description = string.Format("An `AggregateException` occured. Inner `{2}`: \n```{0}``` " + (showStackTrace ? "**Stacktrace** ```haskell\n{1}\n```" : "{1}"), 
                    aggregate.InnerException.Message,
                    showStackTrace ? aggregate.InnerException.StackTrace : "", 
                    aggregate.InnerException.GetType().Name);
            }
            else
            {
                builder.Description = string.Format("An `{2}` has occured: \n```{0}``` " + (showStackTrace ? "**Stacktrace** ```haskell\n{1}\n```" : "{1}"), 
                    exception.Message,
                    showStackTrace ? exception.StackTrace : "", 
                    exception.GetType().Name);
            }
            return builder;
		}
public static DiscordEmbedBuilder ToEmbed ( this Exception exception , bool showStackTrace = true ) { DiscordEmbedBuilder builder = new DiscordEmbedBuilder ( ) ; builder . Color = ErrorColour ; if ( exception is AggregateException ) { AggregateException aggregate = exception as AggregateException ; builder . Description = string . Format ( " \n " + ( showStackTrace ? " \n \n " : " " ) , aggregate . InnerException . Message , showStackTrace ? aggregate . InnerException . StackTrace : " " , aggregate . InnerException . GetType ( ) . Name ) ; } else { builder . Description = string . Format ( " \n " + ( showStackTrace ? " \n \n " : " " ) , exception . Message , showStackTrace ? exception . StackTrace : " " , exception . GetType ( ) . Name ) ; } return builder ; }
Turns the exception into a embeded format.
Turns the exception into a embeded format .
//Aggregate exceptions, we should log the first one only.
None
Exception
this
showStackTrace
bool
None
exception
None