using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace YQLUtils
{
    public class YQLUtil
    {
        
        public static string get_Exception(Exception E)
        {
            StringBuilder buffer = new StringBuilder();
            UTF8Encoding utf8 = new UTF8Encoding();
            if (E != null)
            {
                var stackTrace = new StackTrace(E, true);
                foreach (var frame in stackTrace.GetFrames())
                    buffer.Append($"FileName: {frame.GetFileName()} MethodName: {frame.GetMethod().Name} Line: {frame.GetFileLineNumber()} Message:{E.ToString()}\n\r");

            }
            if (buffer.Length <= 0)
                buffer.Append("\n\r");
            var data = utf8.GetBytes(buffer.ToString());
            return utf8.GetString(data);
        }
        public static void Print_Exception(Exception E)
        {
            Console.Write($"{YQLUtil.get_Exception(E)}");
        }
    }
}
