예제 #1
0
        private bool TrySendError(Error error, out SendErrorCompletedEventArgs completed)
        {
            Exception       exception = null;
            HttpWebResponse response  = null;

            try {
                OnSendingError(error);
                Log.FormattedInfo(typeof(ExceptionlessClient), "Submiting error {0}...", error.Id);

                if (!Configuration.TestMode)
                {
                    RestClient client = CreateClient();
                    response  = client.Post <Error, HttpWebResponse>("error", error);
                    exception = client.Error;
                }
            } catch (Exception ex) {
                exception = ex;
            }

            string id = null;

            if (response == null && !Configuration.TestMode)
            {
                Log.FormattedError(typeof(ExceptionlessClient), "Error submit response was null: {0}", exception.Message);
            }
            else
            {
                if (response.IsSuccessStatusCode() && !response.TryParseCreatedUri(out id))
                {
                    exception = new Exception("Unable to parse the error id from the response object.", exception);
                }

                if (response.ShouldUpdateConfiguration(LocalConfiguration.CurrentConfigurationVersion))
                {
                    UpdateConfiguration(true);
                }
            }

            completed = new SendErrorCompletedEventArgs(id, exception, false, error);
            OnSendErrorCompleted(completed);

            // if there was a conflict, then the server already has the error and we should delete it locally
            if (response != null && response.StatusCode == HttpStatusCode.Conflict)
            {
                return(true);
            }

            return(response.IsSuccessStatusCode() || Configuration.TestMode);
        }
예제 #2
0
        /// <summary>
        /// Raises the <see cref="SendErrorCompleted" /> event.
        /// </summary>
        /// <param name="e">The <see cref="SendErrorCompletedEventArgs" /> instance containing the event data.</param>
        protected void OnSendErrorCompleted(SendErrorCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Log.FormattedError(typeof(ExceptionlessClient), "Sending error report failed: {0}", e.Error.Message);
            }
            else
            {
                Log.FormattedDebug(typeof(ExceptionlessClient), "Report completed for {0}.", e.ErrorId);
            }

            if (SendErrorCompleted != null)
            {
                SendErrorCompleted(this, e);
            }
        }
예제 #3
0
        private void SendReport(Manifest manifest)
        {
            Log.FormattedInfo(typeof(ExceptionlessClient), "Sending Manifest '{0}'", manifest.Id);

            if (manifest.IsSent || !manifest.ShouldRetry())
            {
                Log.FormattedInfo(typeof(ExceptionlessClient), "Manifest was not submitted. IsSent: {0}, ShouldRetry: {1}, Attempts: {2}, Last Sent: {3}", manifest.IsSent, manifest.ShouldRetry(), manifest.Attempts, manifest.LastAttempt);
                return;
            }

            manifest.Attempts++;

            SendErrorCompletedEventArgs completed = null;
            Error error = _queue.GetError(manifest.Id);

            if (error == null)
            {
                manifest.LastError = String.Format("Could not load file '{0}'.", manifest.Id);
                manifest.IsSent    = true;
                Log.FormattedInfo(typeof(ExceptionlessClient), manifest.LastError);
            }
            else
            {
                manifest.IsSent = TrySendError(error, out completed);
            }

            manifest.LastAttempt = DateTime.UtcNow;

            if (manifest.IsSent || completed == null)
            {
                return;
            }

            Log.FormattedError(typeof(ExceptionlessClient), completed.Error, "Problem processing manifest '{0}'.", manifest.Id);
            manifest.LogError(completed.Error);
            manifest.BreakProcessing = (completed.Error is SecurityException);
        }
        private bool TrySendError(Error error, out SendErrorCompletedEventArgs completed) {
            Exception exception = null;
            HttpWebResponse response = null;

            try {
                OnSendingError(error);
                Log.FormattedInfo(typeof(ExceptionlessClient), "Submiting error {0}...", error.Id);

                if (!Configuration.TestMode) {
                    RestClient client = CreateClient();
                    response = client.Post<Error, HttpWebResponse>("error", error);
                    exception = client.Error;
                }
            } catch (Exception ex) {
                exception = ex;
            }

            string id = null;

            if (response == null && !Configuration.TestMode)
                Log.FormattedError(typeof(ExceptionlessClient), "Error submit response was null: {0}", exception.Message);
            else {
                if (response.IsSuccessStatusCode() && !response.TryParseCreatedUri(out id))
                    exception = new Exception("Unable to parse the error id from the response object.", exception);

                if (response.ShouldUpdateConfiguration(LocalConfiguration.CurrentConfigurationVersion))
                    UpdateConfiguration(true);
            }

            completed = new SendErrorCompletedEventArgs(id, exception, false, error);
            OnSendErrorCompleted(completed);

            // if there was a conflict, then the server already has the error and we should delete it locally
            if (response != null && response.StatusCode == HttpStatusCode.Conflict)
                return true;

            return response.IsSuccessStatusCode() || Configuration.TestMode;
        }
        /// <summary>
        /// Raises the <see cref="SendErrorCompleted" /> event.
        /// </summary>
        /// <param name="e">The <see cref="SendErrorCompletedEventArgs" /> instance containing the event data.</param>
        protected void OnSendErrorCompleted(SendErrorCompletedEventArgs e) {
            if (e.Error != null)
                Log.FormattedError(typeof(ExceptionlessClient), "Sending error report failed: {0}", e.Error.Message);
            else
                Log.FormattedDebug(typeof(ExceptionlessClient), "Report completed for {0}.", e.ErrorId);

            if (SendErrorCompleted != null)
                SendErrorCompleted(this, e);
        }