/// <summary> /// Initializes a new instance of the <see cref="Body"/> class. /// </summary> /// <param name="exceptions">The exceptions.</param> public Body(IEnumerable <System.Exception> exceptions) { Assumption.AssertNotNullOrEmpty(exceptions, nameof(exceptions)); var allExceptions = exceptions as System.Exception[] ?? exceptions.ToArray(); TraceChain = allExceptions.Select(e => new Trace(e)).ToArray(); Validate(); }
internal Trace(string callStack, string exceptionInfo) { Assumption.AssertNotNullOrEmpty(callStack, nameof(callStack)); Assumption.AssertNotNullOrEmpty(exceptionInfo, nameof(exceptionInfo)); string[] entries = callStack.Split(new [] { Environment.NewLine, }, StringSplitOptions.None); List <DTOs.Frame> frames = new List <Frame>(entries.Length); foreach (var entry in entries) { if (string.IsNullOrWhiteSpace(entry)) { continue; } frames.Add(new DTOs.Frame(entry)); } if (frames.Count > 0) { this.Frames = frames.ToArray(); } entries = exceptionInfo.Split(new [] { ": ", }, StringSplitOptions.None); DTOs.Exception ex = null; switch (entries.Length) { case 3: ex = new DTOs.Exception(entries[0], entries[1], entries[2]); break; case 2: ex = new DTOs.Exception(entries[0], entries[1]); break; case 1: ex = new DTOs.Exception(entries[0]); break; default: System.Diagnostics.Trace.WriteLine( $"Unexpected exception info component/entry..." ); break; } if (ex != null) { this.Exception = ex; } }
/// <summary> /// Initializes a new instance of the <see cref="Body"/> class. /// </summary> /// <param name="exceptions">The exceptions.</param> public Body(IEnumerable <System.Exception> exceptions) { Assumption.AssertNotNullOrEmpty(exceptions, nameof(exceptions)); if (exceptions.Count() > 1) { this.OriginalException = new AggregateException(exceptions); } else { this.OriginalException = exceptions.FirstOrDefault(); } var allExceptions = exceptions as System.Exception[] ?? exceptions.ToArray(); TraceChain = allExceptions.Select(e => new Trace(e)).ToArray(); Validate(); }
internal Trace(string callStack, string exceptionInfo) { Assumption.AssertNotNullOrEmpty(callStack, nameof(callStack)); Assumption.AssertNotNullOrEmpty(exceptionInfo, nameof(exceptionInfo)); string[] entries = callStack.Split(new [] { Environment.NewLine, }, StringSplitOptions.None); List <DTOs.Frame> frames = new List <Frame>(entries.Length); foreach (var entry in entries) { if (string.IsNullOrWhiteSpace(entry)) { continue; } frames.Add(new DTOs.Frame(entry)); } this.Frames = frames.ToArray(); entries = exceptionInfo.Split(new [] { ": ", }, StringSplitOptions.None); DTOs.Exception ex; switch (entries.Length) { case 3: ex = new DTOs.Exception(entries[0], entries[1], entries[2]); break; case 2: ex = new DTOs.Exception(entries[0], entries[1]); break; case 1: ex = new DTOs.Exception(entries[0]); break; default: traceSource.TraceEvent(TraceEventType.Warning, 0, $"Unexpected exception info component/entry..."); ex = new DTOs.Exception("Default exception mock!"); break; } this.Exception = ex; }
/// <summary> /// Initializes a new instance of the <see cref="RollbarClientBase"/> class. /// </summary> /// <param name="rollbarLoggerConfig">The rollbar logger configuration.</param> /// <exception cref="Rollbar.RollbarException"> /// Undefined destination end-point! /// </exception> protected RollbarClientBase(IRollbarLoggerConfig rollbarLoggerConfig) { Assumption.AssertNotNull( rollbarLoggerConfig, nameof(rollbarLoggerConfig) ); Assumption.AssertNotNullOrEmpty( rollbarLoggerConfig.RollbarDestinationOptions.EndPoint, nameof(rollbarLoggerConfig.RollbarDestinationOptions.EndPoint) ); if (string.IsNullOrWhiteSpace(rollbarLoggerConfig.RollbarDestinationOptions.EndPoint)) { throw new RollbarException(InternalRollbarError.InfrastructureError, "Undefined destination end-point!"); } this._rollbarLoggerConfig = rollbarLoggerConfig; this._payloadPostUri = new Uri($"{rollbarLoggerConfig.RollbarDestinationOptions.EndPoint}item/"); var sp = ServicePointManager.FindServicePoint( new Uri(rollbarLoggerConfig.RollbarDestinationOptions.EndPoint) ); try { sp.ConnectionLeaseTimeout = 60 * 1000; // 1 minute } catch (NotImplementedException) { // just a crash prevention. // this is a work around the unimplemented property within Mono runtime... } this._payloadScrubber = new(rollbarLoggerConfig.RollbarDataSecurityOptions.GetFieldsToScrub()); this._payloadTruncator = new(null); }