public void DemonstrateStateCapture() { var criticalObj = new InstanceType(); criticalObj.AutoProperty = -100; try { ///... /// oh, no - we have an exception: throw new System.Exception("An exception with state capture!"); ///... } catch (System.Exception ex) { // capture state of this instance: var state = RollbarAssistant.CaptureState(this, "Self"); // also, capture state of some other critical object: state = new Dictionary <string, object>(state.Concat(RollbarAssistant.CaptureState(criticalObj, nameof(criticalObj)))); // also, capture current state of a static type: state = new Dictionary <string, object>(state.Concat(RollbarAssistant.CaptureState(typeof(StaticType)))); // report the captured states along with the caught exception: //RollbarLocator.RollbarInstance.AsBlockingLogger(TimeSpan.FromMilliseconds(10000)).Error(ex, state); RollbarLocator.RollbarInstance.Error(ex, state); } }
private static void DemonstrateExceptionSourceStateCapture() { Vehicle vehicle = new Sedan(200) { Brand = "Audi", Model = "A4 Quattro", Type = Sedan.SedanType.PassengerCar, }; try { vehicle.Start(); } catch (System.Exception ex) { // capture state of vehicle instance: var state = RollbarAssistant.CaptureState(vehicle, "StartedVehicle"); // also, capture state of the Game static type: RollbarAssistant.CaptureState(typeof(Game), state); // report the captured states along with the caught exception: RollbarLocator.RollbarInstance .AsBlockingLogger(TimeSpan.FromMilliseconds(10000)) .Error(new ApplicationException("Application exception with a state capture.", ex), state); } }
public void TestCaptureStateOfStaticType() { var stateVars = RollbarAssistant.CaptureState(typeof(StaticType)); Assert.AreEqual(4, stateVars.Count); foreach (var key in stateVars.Keys) { Console.WriteLine($"{key} = {stateVars[key]}"); } }
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { var state = RollbarAssistant.CaptureState(this, "Self"); RollbarLocator.RollbarInstance.Error(e.Exception, new Dictionary <string, object>() { ["version"] = Settings.Version.ToString() }); MessageBox.Show("This crash will be automatically sended to author", "The application is crashed"); }
public void TestCaptureStateOfEnum_KindOf() { var objUnderTest = EnumType.Two; var stateVars = RollbarAssistant.CaptureState(objUnderTest, nameof(objUnderTest)); Assert.IsNull(stateVars); stateVars = RollbarAssistant.CaptureState(typeof(EnumType)); Assert.IsNull(stateVars); }
public void TestCombinedStateCapture() { var objUnderTest = new InstanceType(); var combinedState = RollbarAssistant.CaptureState(objUnderTest, nameof(objUnderTest)); RollbarAssistant.CaptureState(typeof(StaticType), combinedState); Assert.AreEqual( RollbarAssistant.CaptureState(objUnderTest, nameof(objUnderTest)).Count + RollbarAssistant.CaptureState(typeof(StaticType)).Count , combinedState.Count ); }
public void TestCaptureStateOfObjectInstance() { var objUnderTest = new InstanceType(); var stateVars = RollbarAssistant.CaptureState(objUnderTest, nameof(objUnderTest)); Assert.AreEqual(2 + 4, stateVars.Count); foreach (var key in stateVars.Keys) { Console.WriteLine($"{key} = {stateVars[key]}"); } }
public void TestCaptureStateOfInterface_KindOf() { var stateVars = RollbarAssistant.CaptureState(typeof(IInterface)); Assert.IsNull(stateVars); }