/// <summary> /// Tries the posting. /// </summary> /// <param name="payloadRecord">The payload record.</param> /// <returns>RollbarResponse.</returns> private RollbarResponse TryPosting(PayloadRecord payloadRecord) { //Payload payload = JsonConvert.DeserializeObject<Payload>(payloadRecord.PayloadJson); //IRollbarConfig config = payload.Data.Notifier.Configuration; IRollbarConfig config = JsonConvert.DeserializeObject <RollbarConfig>(payloadRecord.ConfigJson); RollbarClient rollbarClient = new RollbarClient(config); try { RollbarResponse response = rollbarClient.PostAsJson(config.EndPoint, config.AccessToken, payloadRecord.PayloadJson); return(response); } catch (System.Exception ex) { this.OnRollbarEvent( new CommunicationErrorEventArgs(null, payloadRecord.PayloadJson, ex, 0) ); RollbarErrorUtility.Report( null, payloadRecord, InternalRollbarError.PersistentPayloadRecordRepostError, "While trying to report a stored payload...", ex, null ); return(null); } }
private RollbarResponse Process(Payload payload, RollbarConfig config) { var client = new RollbarClient(config); IEnumerable <string> safeScrubFields = config.ScrubFields; RollbarResponse response = null; int retries = 3; while (retries > 0) { try { response = client.PostAsJson(payload, safeScrubFields); } catch (WebException ex) { retries--; this.OnRollbarEvent( new CommunicationErrorEventArgs(config, payload, ex, retries) ); continue; } catch (ArgumentNullException ex) { retries = 0; this.OnRollbarEvent( new CommunicationErrorEventArgs(config, payload, ex, retries) ); continue; } catch (System.Exception ex) { retries = 0; this.OnRollbarEvent( new CommunicationErrorEventArgs(config, payload, ex, retries) ); continue; } retries = 0; } if (response != null) { this.OnRollbarEvent( new CommunicationEventArgs(config, payload, response) ); } return(response); }