Example #1
0
 public void CacheError(BugSenseExceptionRequest req, bool isFatal)
 {
     Task t = new Task(async () =>
         {
             LogError err = new LogError(req, isFatal);
             Helpers.Log("begin(CacheError)");
             string res = await err.Execute();
             Helpers.Log("end(CacheError): " + res);
         });
     t.Start();
 }
Example #2
0
 private string GetJson(BugSenseExceptionRequest request)
 {
     try
     {
         Helpers.Log("LogError 1/2 :: Serializing JSON");
         using (MemoryStream ms = new MemoryStream())
         {
             _jsonSerializer.WriteObject(ms, request);
             var array = ms.ToArray();
             string json = Encoding.UTF8.GetString(array, 0, array.Length);
             Helpers.Log("LogError 1/2 :: Done serializing JSON");
             return json;
         }
     }
     catch (Exception)
     {
         Helpers.Log("LogError 1/2 :: Error during JSON serialization");
         return string.Empty;
     }
 }
Example #3
0
		private string CacheTestHandledException (string uuid)
		{
			string res = "";
			
			Exception exc1 = new Exception ("Test exception");
			var request = new BugSenseExceptionRequest (exc1.ToBugSenseEx (null, true, "", "_ping|ev1|ev2"),
				BugSenseEnvironment.GetEnvironment ("test", "0.0.0.0", uuid, true),
				new Dictionary<string, string> () {
					{ "k1", "val1"},
					{ "k2", "val2"},
					{ "k3", "val3"}
			});
			
			LogError err = new LogError (request, false);
			Task.Run (async () => {
				res = await err.Execute ();
			}).Wait ();
			
			return res;
		}
Example #4
0
 public LogError(BugSenseExceptionRequest request, bool isFatal)
 {
     _request = request;
     _isFatal = isFatal;
 }
Example #5
0
        public void SendErrorNow(BugSenseExceptionRequest req, bool isFatal,
			bool debugFixResponse = false)
        {
            Task t = new Task(async () =>
                {
                    try
                    {
                        Helpers.Log("begin(SendErrorNow-1)");
                        LogError err = new LogError(req, isFatal);
                        string str = await err.Execute();
                        if (!string.IsNullOrEmpty(str))
                        {
                            try
                            {
                                SendRequest msg = null;
                                if (isFatal)
                                    msg = new SendRequest(str, FixNotificationAndDieAction);
                                else
                                    msg = new SendRequest(str, FixNotificationAction);
                                if (debugFixResponse)
                                    msg.setDebugFixedResponse(true);
                                _lockToSend.WaitOne();
                                Helpers.Log("begin(SendErrorNow-2)");
                                bool res = await msg.Execute();
                                Helpers.Log("end(SendErrorNow-2): " + res);
                                _lockToSend.Release();
                            }
                            catch (Exception)
                            {
                                Helpers.Log("fail(SendErrorNow)");
                            }
                        }
                        Helpers.Log("end(SendErrorNow-1)");
                    }
                    catch (Exception)
                    {
                        Helpers.Log("fail(SendErrorNow)");
                    }
                });
            t.Start();
        }
        public bool IsSimilarTo(BugSenseExceptionRequest that)
        {
            bool res = false;

            res = LogData.Count == that.LogData.Count && !LogData.Except(that.LogData).Any();
            res = res && Exception.IsSimilarTo(that.Exception);
            res = res && AppEnvironment.IsSimilarTo(that.AppEnvironment);
            res = res && Client.IsSimilarTo(that.Client);
            res = res && Request.IsSimilarTo(that.Request);

            return res;
        }