private static void LogUnitaskException(System.Runtime.ExceptionServices.ExceptionDispatchInfo __result)
 {
     if (__result != null)
     {
         UnityEngine.Debug.LogWarning("Exception has been thrown inside a UniTask, it might crash the task if not caught! (ExceptionHolder.GetException)\n" + __result.SourceException);
     }
 }
Example #2
0
        void OnFail(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionInfo)
        {
            if (!hasFailed)
            {
                hasFailed = true;
            }

            System.Diagnostics.StackTrace   stackTrace    = new System.Diagnostics.StackTrace(exceptionInfo.SourceException, 0, true);
            System.Diagnostics.StackFrame[] currentFrames = stackTrace.GetFrames();

            if (frames == null)
            {
                frames = currentFrames;
            }
            else
            {
                // When the exception is thrown, OnFail can be called multiple times.
                // With every next call we see bigger part of the call stack, so we save the biggest call stack
                if (currentFrames.Length > frames.Length)
                {
                    Debug.Assert((frames.Length == 0) || (frames[0].ToString() == currentFrames[0].ToString()));
                    frames = currentFrames;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Issues an HTTP request for the current request context.
        /// </summary>
        /// <typeparam name="T">The response type for the current request.</typeparam>
        /// <param name="executionContext">The execution context, it contains the
        /// request and response context.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public override async System.Threading.Tasks.Task <T> InvokeAsync <T>(IExecutionContext executionContext)
        {
            IHttpRequest <TRequestContent> httpRequest = null;

            try
            {
                SetMetrics(executionContext.RequestContext);
                IRequest wrappedRequest = executionContext.RequestContext.Request;
                httpRequest = CreateWebRequest(executionContext.RequestContext);
                httpRequest.SetRequestHeaders(wrappedRequest.Headers);

                using (executionContext.RequestContext.Metrics.StartEvent(Metric.HttpRequestTime))
                {
                    // Send request body if present.
                    if (wrappedRequest.HasRequestBody())
                    {
                        System.Runtime.ExceptionServices.ExceptionDispatchInfo edi = null;
                        try
                        {
                            // In .NET Framework, there needs to be a cancellation token in this method since GetRequestStreamAsync
                            // does not accept a cancellation token. A workaround is used. This isn't necessary in .NET Standard
                            // where the stream is a property of the request.
#if BCL45
                            var requestContent = await httpRequest.GetRequestContentAsync(executionContext.RequestContext.CancellationToken).ConfigureAwait(false);
                            await WriteContentToRequestBodyAsync(requestContent, httpRequest, executionContext.RequestContext).ConfigureAwait(false);
#else
                            var requestContent = await httpRequest.GetRequestContentAsync().ConfigureAwait(false);

                            WriteContentToRequestBody(requestContent, httpRequest, executionContext.RequestContext);
#endif
                        }
                        catch (Exception e)
                        {
                            edi = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(e);
                        }

                        if (edi != null)
                        {
                            await CompleteFailedRequest(executionContext, httpRequest).ConfigureAwait(false);

                            edi.Throw();
                        }
                    }

                    var response = await httpRequest.GetResponseAsync(executionContext.RequestContext.CancellationToken).
                                   ConfigureAwait(false);

                    executionContext.ResponseContext.HttpResponse = response;
                }
                // The response is not unmarshalled yet.
                return(null);
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Adds an item to the cache.
        /// </summary>
        /// <param name="store">The store storing the cache data.</param>
        /// <param name="name">The name of the cache item.</param>
        /// <param name="content">The cached data.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous caching operation.</returns>
        public async Task Add(String name, Stream content, String store)
        {
            Contract.Requires <ArgumentNullException>(name != null);
            Contract.Requires <ArgumentNullException>(content != null);
            Contract.Requires <ArgumentNullException>(store != null);

            System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionInfo = null;
            try
            {
                long length = content.Length;
                await this.WriteToFileAsync(content, await this.OpenStore(store), name);

                cacheEventSource.ItemStored(name, store, length);
            }
            catch (IOException ex)
            {
                exceptionInfo = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex);
            }

            if (exceptionInfo != null) // Little hacky (but required!) as we can't use async / await inside a catch-block
            {
                int hresult = exceptionInfo.SourceException.HResult & 0xFFFF;
                if (hresult == 0x70 || hresult == 0x27) // HResults for disk full.
                {
                    await this.Invalidate();
                }
                else
                {
                    exceptionInfo.Throw();
                }
            }
        }
 public void SetException(System.Runtime.ExceptionServices.ExceptionDispatchInfo edi, TaskScheduler sheduler = null)
 {
     lock (_lock)
     {
         _completionAction = () => { edi.Throw(); };
         Complete(sheduler);
     }
 }
 /// <summary>
 /// Конструктор SendOrPostCallbackSyncThreadPoolWorkItem
 /// </summary>
 /// <param name="action">Исполняемое действие</param>
 /// <param name="state">Состояние</param>
 /// <param name="allowExecutionContextFlow">Можно ли захватывать контекст исполнения</param>
 /// <param name="preferFairness">Требовать постановку в общую очередь</param>
 public SendOrPostCallbackSyncThreadPoolWorkItem(SendOrPostCallback action, object state, bool allowExecutionContextFlow, bool preferFairness)
     : base(allowExecutionContextFlow, preferFairness)
 {
     Contract.Requires(action != null);
     _action          = action;
     _state           = state;
     _isCompleted     = false;
     _isCancelled     = false;
     _exception       = null;
     _syncObject      = new object();
     _taskProcessFlag = 0;
 }
Example #7
0
        /// <summary>
        /// Issues an HTTP request for the current request context.
        /// </summary>
        /// <typeparam name="T">The response type for the current request.</typeparam>
        /// <param name="executionContext">The execution context, it contains the
        /// request and response context.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public override async System.Threading.Tasks.Task <T> InvokeAsync <T>(IExecutionContext executionContext)
        {
            IHttpRequest <TRequestContent> httpRequest = null;

            try
            {
                SetMetrics(executionContext.RequestContext);
                IRequest wrappedRequest = executionContext.RequestContext.Request;
                httpRequest = CreateWebRequest(executionContext.RequestContext);
                httpRequest.SetRequestHeaders(wrappedRequest.Headers);

                using (executionContext.RequestContext.Metrics.StartEvent(Metric.HttpRequestTime))
                {
                    // Send request body if present.
                    if (wrappedRequest.HasRequestBody())
                    {
                        System.Runtime.ExceptionServices.ExceptionDispatchInfo edi = null;
                        try
                        {
                            var requestContent = await httpRequest.GetRequestContentAsync().ConfigureAwait(false);

                            WriteContentToRequestBody(requestContent, httpRequest, executionContext.RequestContext);
                        }
                        catch (Exception e)
                        {
                            edi = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(e);
                        }

                        if (edi != null)
                        {
                            await CompleteFailedRequest(executionContext, httpRequest).ConfigureAwait(false);

                            edi.Throw();
                        }
                    }

                    var response = await httpRequest.GetResponseAsync(executionContext.RequestContext.CancellationToken).
                                   ConfigureAwait(false);

                    executionContext.ResponseContext.HttpResponse = response;
                }
                // The response is not unmarshalled yet.
                return(null);
            }
            finally
            {
                if (httpRequest != null)
                {
                    httpRequest.Dispose();
                }
            }
        }
Example #8
0
        internal void RestoreExceptionDispatchInfo(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionDispatchInfo)
        {
#if MONO
            captured_traces   = (StackTrace[])exceptionDispatchInfo.BinaryStackTraceArray;
            _stackTrace       = null;
            _stackTraceString = null;
#else
            bool fCanProcessException = !(IsImmutableAgileException(this));
            // Restore only for non-preallocated exceptions
            if (fCanProcessException)
            {
                // Take a lock to ensure only one thread can restore the details
                // at a time against this exception object that could have
                // multiple ExceptionDispatchInfo instances associated with it.
                //
                // We do this inside a finally clause to ensure ThreadAbort cannot
                // be injected while we have taken the lock. This is to prevent
                // unrelated exception restorations from getting blocked due to TAE.
                try{}
                finally
                {
                    // When restoring back the fields, we again create a copy and set reference to them
                    // in the exception object. This will ensure that when this exception is thrown and these
                    // fields are modified, then EDI's references remain intact.
                    //
                    // Since deep copying can throw on OOM, try to get the copies
                    // outside the lock.
                    object _stackTraceCopy     = (exceptionDispatchInfo.BinaryStackTraceArray == null)?null:DeepCopyStackTrace(exceptionDispatchInfo.BinaryStackTraceArray);
                    object _dynamicMethodsCopy = (exceptionDispatchInfo.DynamicMethodArray == null)?null:DeepCopyDynamicMethods(exceptionDispatchInfo.DynamicMethodArray);

                    // Finally, restore the information.
                    //
                    // Since EDI can be created at various points during exception dispatch (e.g. at various frames on the stack) for the same exception instance,
                    // they can have different data to be restored. Thus, to ensure atomicity of restoration from each EDI, perform the restore under a lock.
                    lock (Exception.s_EDILock)
                    {
#if !MONO
                        _watsonBuckets      = exceptionDispatchInfo.WatsonBuckets;
                        _ipForWatsonBuckets = exceptionDispatchInfo.IPForWatsonBuckets;
#endif
                        _remoteStackTraceString = exceptionDispatchInfo.RemoteStackTrace;
                        SaveStackTracesFromDeepCopy(this, _stackTraceCopy, _dynamicMethodsCopy);
                    }
                    _stackTraceString = null;

                    // Marks the TES state to indicate we have restored foreign exception
                    // dispatch information.
                    Exception.PrepareForForeignExceptionRaise();
                }
            }
#endif
        }
Example #9
0
        /// <summary>
        /// Invokes the inner handler and performs a retry, if required as per the
        /// retry policy.
        /// </summary>
        /// <typeparam name="T">The response type for the current request.</typeparam>
        /// <param name="executionContext">The execution context, it contains the
        /// request and response context.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public override async System.Threading.Tasks.Task <T> InvokeAsync <T>(IExecutionContext executionContext)
        {
            var  requestContext  = executionContext.RequestContext;
            var  responseContext = executionContext.ResponseContext;
            bool shouldRetry     = false;

            await this.RetryPolicy.ObtainSendTokenAsync(executionContext, null).ConfigureAwait(false);

            do
            {
                System.Runtime.ExceptionServices.ExceptionDispatchInfo capturedException = null;

                try
                {
                    SetRetryHeaders(requestContext);
                    T result = await base.InvokeAsync <T>(executionContext).ConfigureAwait(false);

                    this.RetryPolicy.NotifySuccess(executionContext);
                    return(result);
                }
                catch (Exception e)
                {
                    capturedException = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(e);
                }

                if (capturedException != null)
                {
                    shouldRetry = await this.RetryPolicy.RetryAsync(executionContext, capturedException.SourceException).ConfigureAwait(false);

                    if (!shouldRetry)
                    {
                        LogForError(requestContext, capturedException.SourceException);
                        capturedException.Throw();
                    }
                    else
                    {
                        requestContext.Retries++;
                        requestContext.Metrics.SetCounter(Metric.AttemptCount, requestContext.Retries);
                        LogForRetry(requestContext, capturedException.SourceException);
                    }

                    await this.RetryPolicy.ObtainSendTokenAsync(executionContext, capturedException.SourceException).ConfigureAwait(false);
                }

                PrepareForRetry(requestContext);

                using (requestContext.Metrics.StartEvent(Metric.RetryPauseTime))
                    await RetryPolicy.WaitBeforeRetryAsync(executionContext).ConfigureAwait(false);
            } while (shouldRetry);
            throw new AmazonClientException("Neither a response was returned nor an exception was thrown in the Runtime RetryHandler.");
        }
Example #10
0
        // For ExceptionDispatchInfo
        internal void RestoreExceptionDispatchInfo(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionDispatchInfo)
        {
            if (captured_traces != null)
            {
                Array.Resize(ref captured_traces, captured_traces.Length + 1);
            }
            else
            {
                captured_traces = new StackTrace [1];
            }
            captured_traces [captured_traces.Length - 1] = new StackTrace(this, 0, true, true);

            trace_ips = null;
        }
        /// <summary>
        /// Метод исполнения задачи
        /// </summary>
        protected sealed override void RunInner()
        {
            if (Interlocked.Exchange(ref _taskProcessFlag, 1) != 0)
            {
                throw new InvalidOperationException("Can't execute SendOrPostCallbackSyncThreadPoolWorkItem cause it was already executed or cancelled");
            }

            try
            {
                _action(_state);
            }
            catch (Exception ex)
            {
                _exception = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex);
            }
            finally
            {
                lock (_syncObject)
                {
                    _isCompleted = true;
                    Monitor.PulseAll(_syncObject);
                }
            }
        }
 public StreamBindingFailureMessage(string id, System.Runtime.ExceptionServices.ExceptionDispatchInfo bindingFailure)
 {
 }
Example #13
0
        public static void ReadLineAndSendLoop(IApplicationClient InnerClient, Action <SecureContext> SetSecureContext, Boolean UseOld, Object Lockee)
        {
            var            NeedToExit  = false;
            AutoResetEvent NeedToCheck = new AutoResetEvent(false);

            System.Runtime.ExceptionServices.ExceptionDispatchInfo edi = null;
            InnerClient.ServerShutdown += e =>
            {
                Console.WriteLine("服务器已关闭。");
                lock (Lockee)
                {
                    NeedToExit = true;
                }
                NeedToCheck.Set();
            };
            InnerClient.Error += e =>
            {
                var m = e.Message;
                Console.WriteLine(m);
            };
            InnerClient.MessageReceived    += e => Console.WriteLine(e.Content);
            InnerClient.MessageReceivedAt2 += e =>
            {
                if (e.Title != "")
                {
                    Console.WriteLine(e.Title);
                }
                foreach (var Line in e.Lines)
                {
                    Console.WriteLine(Line);
                }
            };
            ((Func <Task>)(async() =>
            {
                var r = await InnerClient.CheckSchemaVersion(new CheckSchemaVersionRequest {
                    Hash = UseOld ? "D7FFBD0D2E5D7274" : InnerClient.Hash.ToString("X16")
                });
                if (r.OnHead)
                {
                }
                else if (r.OnSupported)
                {
                    Console.WriteLine("客户端不是最新版本,但服务器可以支持。");
                }
                else if (r.OnNotSupported)
                {
                    Console.WriteLine("客户端版本不受支持。");
                    lock (Lockee)
                    {
                        NeedToExit = true;
                    }
                    NeedToCheck.Set();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }))();
            while (true)
            {
                String Line = null;
                ThreadPool.QueueUserWorkItem(o =>
                {
                    var l = Console.ReadLine();
                    lock (Lockee)
                    {
                        Line = l;
                    }
                    NeedToCheck.Set();
                });
                while (true)
                {
                    if (NeedToExit)
                    {
                        return;
                    }
                    String l;
                    lock (Lockee)
                    {
                        l = Line;
                    }
                    if (l != null)
                    {
                        break;
                    }
                    NeedToCheck.WaitOne();
                    if (edi != null)
                    {
                        edi.Throw();
                    }
                }
                lock (Lockee)
                {
                    HandleLine(InnerClient, SetSecureContext, UseOld, Line).ContinueWith(tt =>
                    {
                        if (tt.IsFaulted)
                        {
                            edi = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(tt.Exception.InnerException ?? tt.Exception);
                            NeedToCheck.Set();
                            return;
                        }
                        if (!tt.Result)
                        {
                            lock (Lockee)
                            {
                                NeedToExit = true;
                            }
                            NeedToCheck.Set();
                        }
                    });
                }
            }
        }
Example #14
0
 public virtual void OnFail(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionDispatchInfo)
 {
 }
Example #15
0
 public virtual void Fail(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionInfo)
 {
     OnFail?.Invoke(exceptionInfo);
 }
 public InvocationBindingFailureMessage(string invocationId, string target, System.Runtime.ExceptionServices.ExceptionDispatchInfo bindingFailure) : base(default(string))
 {
 }
Example #17
0
        public void LogPrintErrorMessage(Exception exx, System.Threading.SynchronizationContext sCtx = null, List <string> list = null, [CallerMemberName] string callingMethod = "", [CallerFilePath] string callingFilePath = "", [CallerLineNumber] int callingFileLineNumber = 0, bool isLogFile = true)
        {
            SyncContext = sCtx;
            Dictionary <string, string> dictionaryMap = new Dictionary <string, string>();

            System.Runtime.ExceptionServices.ExceptionDispatchInfo ex = null;
            string sdatetime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt");
            string strdatetime = $" {sdatetime} :";
            string datetime    = strdatetime;

            try
            {
                ex = System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(exx);
                builderforWriteExceptionText.Length = 0;
                builder.Length = 0;
                builder.AppendFormat("{0}", "\r\n\r\n");
                builder.AppendFormat("{0}", "Beginning Exception Report ==================================================================================================================================================================================================================");
                builder.AppendFormat("{0}", "\r\n");


                builderforWriteExceptionText.AppendFormat("[{0}] >>>> [LOG_PRINT_ERROR_MESSAGE_Log.ErrorD] !!!!!!!!!!! ---> at [ Line No. : {1} ] : [ Calling Method --> {2} ] [ File name --> {3}]", datetime, callingFileLineNumber, callingMethod, callingFilePath);

                builderforWriteExceptionText.Append(ex.SourceException.Message + "|");

                dictionaryMap.Add("Log.Errord line number >>>>>>> :", string.Format("[LOG_PRINT_ERROR_MESSAGE_Log.ErrorD] !!!!!!!!!!! ---> at [ Line No. : {1} ] : [ Calling Method --> {2} ] [ File name --> {3}]", datetime, callingFileLineNumber, callingMethod, callingFilePath));


                builder.AppendFormat("[{0}] >>>> [LOG_PRINT_ERROR_MESSAGE_Log.ErrorD !!!!!!!!!!! ---> at [ Line No. : {1} ] : [ Calling Method --> {2} ] [ File name --> {3}]", datetime, callingFileLineNumber, callingMethod, callingMethod);
                builder.AppendFormat("{0}", "\r\n");

                if (list != null)
                {
                    string strlist = string.Join("\n", list.ToArray());
                    builder.AppendFormat("&&& went thru these line numbers---- {0}  &&&&&&&&&&&&&&&&&&&&&&&&", strlist);
                    builderforWriteExceptionText.AppendFormat("&&& went thru these line numbers----  {0}  &&&&&&&&&&&&&&&&&&&&&&&& ", strlist);
                    builderforWriteExceptionText.AppendFormat("{0}", "\r\n");
                }


                var stOuter         = new StackTrace(ex.SourceException, true);
                int frameCountOuter = stOuter.FrameCount;
                //builder.AppendFormat ("[ \n {0} \n>> [Stack Frame count : --->>] --> {1}\n", strdatetime, frameCountOuter.ToString ());
                builder.AppendFormat("[ \n {0} \n >>>>>>>>>>>>>>>>>>>>>>>>>>>>\n [Error Message: --->>] --> {1} \n", strdatetime, ex.SourceException.Message);
                builder.AppendFormat("[ \n {0} \n>> [[Error Targetsite Something has gone horribly wrong with the method : --->> --> {1}\n", strdatetime, ex.SourceException.TargetSite);
                builder.AppendFormat("[ \n {0} \n>> [Error Source: --->>] --> {1}\n", strdatetime, ex.SourceException.Source);
                builder.AppendFormat("[ \n {0} \n >>>>>>>>>>>>>>>>>>>>>>>>>>>>\n [Error StackTrace: --->>] --> {1}\n", strdatetime, ex.SourceException.StackTrace);

                builderforWriteExceptionText.AppendFormat("[ \n {0} \n>> [Stack Frame count : --->>] --> {1}\n", strdatetime, frameCountOuter.ToString());
                builderforWriteExceptionText.AppendFormat("[ \n {0} \n>> [Error Message: --->>] --> {1} \n", strdatetime, ex.SourceException.Message);
                builderforWriteExceptionText.AppendFormat("[ \n {0} \n>> [Error Targetsite Something has gone horribly wrong with the method : --->>] --> {1}\n", strdatetime, ex.SourceException.TargetSite);
                builderforWriteExceptionText.AppendFormat("[ \n {0} \n>> [Error Source: --->>] --> {1}\n", strdatetime, ex.SourceException.Source);
                builderforWriteExceptionText.AppendFormat("[ \n {0} \n>> [Error StackTrace: --->>] --> {1}\n", strdatetime, ex.SourceException.StackTrace);

                var prevfilename = "";
                for (int i = 0; i < frameCountOuter; i++)
                {
                    StackFrame frameOuter = stOuter.GetFrame(i);

                    var filename = frameOuter.GetFileName();

                    var    methodnamer = frameOuter.GetMethod();
                    string methodname  = string.Empty;
                    if (methodnamer != null)
                    {
                        methodname = frameOuter.GetMethod().Name;
                    }
                    var iline = frameOuter.GetFileLineNumber();
                    var line  = Convert.ToString(iline);
                    if (!string.IsNullOrEmpty(filename))
                    {
                        if (prevfilename != filename)
                        {
                            builder.AppendFormat("\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>\n [Exception Caught at Caught at ] ->> [At LineNumber: {1}] >> [MethodName >: {2}] >> [FileName: {3}]", strdatetime, line, methodname, filename);
                            builderforWriteExceptionText.AppendFormat("\n >>>>>>>>>>>>>>>>>>>>>>>>>[\n  :][Exception Caught at Caught at ] ->> [At LineNumber: {1}] >> [MethodName >: {2}] >> [FileName: {3}]", strdatetime, line, methodname, filename);
                            dictionaryMap.Add(">>>>> " + i.ToString() + " : ", string.Format("[Exception Caught at Caught at ] ->> [At LineNumber: {1}] >> [MethodName >: {2}] >> [FileName: {3}]", strdatetime, line, methodname, filename));
                            prevfilename = filename;
                        }
                    }
                }
                builder.Append("\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
                builderforWriteExceptionText.Append("\n >>>>>>>>>>>>>>>>>>>>>>>>>\n");
                if (ex.SourceException.InnerException != null)
                {
                    var sttinner     = new StackTrace(ex.SourceException.InnerException, true);
                    int frameCountin = sttinner.FrameCount;
                    //builder.AppendFormat (" \n {0} \n>> [Inner Stack Frame count : --->>] --> {1}\n", strdatetime, frameCountin.ToString ());
                    builder.AppendFormat(" \n {0} \n>> [Inner Exception Message: --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.Message);
                    builder.AppendFormat(" \n {0} \n>> [Inner Exception Targetsite2 Something has gone horribly wrong with the method : --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.TargetSite);
                    builder.AppendFormat(" \n {0} \n>> [Inner Exception Source: --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.Source);
                    builder.AppendFormat(" \n {0} \n>> [Inner Exception StackTrace: --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.StackTrace);

                    builderforWriteExceptionText.AppendFormat(" \n {0} \n>> [Inner Stack Frame count : --->>] --> {1}\n", strdatetime, frameCountin.ToString());
                    builderforWriteExceptionText.AppendFormat(" \n {0} \n>> [Inner Exception Message: --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.Message);
                    builderforWriteExceptionText.AppendFormat(" \n {0} \n>> [Inner Exception Targetsite2 Something has gone horribly wrong with the method : --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.TargetSite);
                    builderforWriteExceptionText.AppendFormat(" \n {0} \n>> [Inner Exception Source: --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.Source);
                    builderforWriteExceptionText.AppendFormat(" \n {0} \n>> [Inner Exception StackTrace: --->>] --> {1} \n", strdatetime, ex.SourceException.InnerException.StackTrace);

                    var prevfile = "";
                    for (int ii = 0; ii < frameCountin; ii++)
                    {
                        StackFrame framein = sttinner.GetFrame(ii);

                        var filename   = framein.GetFileName();
                        var methodname = framein.GetMethod().Name;
                        var iline      = framein.GetFileLineNumber();
                        var line       = Convert.ToString(iline);

                        if (!string.IsNullOrEmpty(filename))
                        {
                            if (prevfile != filename)
                            {
                                builder.AppendFormat("\n >>>\n {0} [Inner Inner Exception Caught at ] ->> [At LineNumber: {1}] >> [MethodName >: {2}] >> [FileName: {3}]", strdatetime, line, methodname, filename);
                                builderforWriteExceptionText.AppendFormat("\n >>>[\n {0} :][Inner Inner Exception Caught at ] ->> [At LineNumber: {1}] >> [MethodName >: {2}] >> [FileName: {3}]", strdatetime, line, methodname, filename);
                                //dictionaryMap.Add (Guid.NewGuid()  +" : Inner inner Exception Caught at Caught at :", line);
                                dictionaryMap.Add(">>>>>>>>> " + ii.ToString() + " ::", string.Format("[Inner Inner Exception Caught at Caught at ] ->> [At LineNumber: {1}] >> [MethodName >: {2}] >> [FileName: {3}]", strdatetime, line, methodname, filename));
                                prevfile = filename;
                            }
                        }
                    }
                }

                builder.Append("\n[\n");
                builder.AppendFormat("\n {0} :>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [LOG_PRINT_ERROR_MESSAGE ENDS] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!]", strdatetime);
                builder.Append("\n[\n");
                builder.Append("Completed Exception Report ================================================================================================================================================================================================\r\n\r\n");

                builderforWriteExceptionText.AppendFormat("\n[{0}] >>>> [LOG_PRINT_ERROR_MESSAGE ENDS] !!!!!!!!!!!\n", strdatetime);

                UnityEngine.Debug.LogError(builder.ToString());
                //Console.WriteLine(builder.ToString());
                //log the error to the file
                if (isLogFile == true)
                {
                    SyncContext.Post(_ =>
                    {
                        LogExceptionText(builderforWriteExceptionText.ToString());
                    }, null);
                }
            }
            catch (Exception egc)
            {
                UnityEngine.Debug.LogError("----MMM----------MMMMM---------  " + egc.Message);
            }
        }
Example #18
0
 // For ExceptionDispatchInfo
 internal void RestoreExceptionDispatchInfo(System.Runtime.ExceptionServices.ExceptionDispatchInfo exceptionDispatchInfo)
 {
     captured_traces = (StackTrace[])exceptionDispatchInfo.BinaryStackTraceArray;
     trace_ips       = null;
     stack_trace     = null;
 }