Exemplo n.º 1
0
        private const int RSDS_SIGNATURE = 0x53445352; // "RSDS"

        public static RaygunErrorInfo Build(Exception exception)
        {
            Dictionary <IntPtr, RaygunImageInfo> images = new Dictionary <IntPtr, RaygunImageInfo>();

            RaygunErrorInfo errorInfo = BuildErrorInfo(exception, images);

            if (images.Count > 0)
            {
                errorInfo.Images = images.Values.Where(i => i != null).ToArray();
            }

            return(errorInfo);
        }
Exemplo n.º 2
0
        private static RaygunErrorInfo BuildErrorInfo(Exception exception, Dictionary <IntPtr, RaygunImageInfo> images)
        {
            RaygunErrorInfo errorInfo = new RaygunErrorInfo();

            var exceptionType = exception.GetType();

            errorInfo.Message   = exception.Message;
            errorInfo.ClassName = FormatTypeName(exceptionType, true);

            try
            {
                errorInfo.StackTrace = BuildNativeStackTrace(images, exception);
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Failed to get native stack trace information: {e.Message}");
            }

            if (errorInfo.StackTrace == null)
            {
                try
                {
                    errorInfo.StackTrace = BuildStackTrace(exception);
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"Failed to get managed stack trace information: {e.Message}");
                }
            }

            errorInfo.Data = exception.Data;

            AggregateException ae = exception as AggregateException;

            if (ae?.InnerExceptions != null)
            {
                errorInfo.InnerErrors = new RaygunErrorInfo[ae.InnerExceptions.Count];
                int index = 0;
                foreach (Exception e in ae.InnerExceptions)
                {
                    errorInfo.InnerErrors[index] = BuildErrorInfo(e, images);
                    index++;
                }
            }
            else if (exception.InnerException != null)
            {
                errorInfo.InnerError = BuildErrorInfo(exception.InnerException, images);
            }

            return(errorInfo);
        }