private void loadBtn_Click(object sender, EventArgs ea) { try { if (string.IsNullOrEmpty(fileTxt.Text)) { throw new Exception("A Bnk file is required."); } Cursor = Cursors.WaitCursor; // File loading _LoadBnk(fileTxt.Text); // Updates bnk contents _UpdateList(); // Updates info labels _UpdateBnkInfo(); _UpdatePackedInfo(); } catch (Exception e) { _Log.Error(FailureHandler.GetStackTrace(e)); MessageBox.Show(this, e.Message); } finally { Cursor = Cursors.Default; } }
private void loadBtn_Click(object sender, EventArgs ea) { try { if (string.IsNullOrEmpty(fileTxt.Text)) { throw new Exception("A Xmb file is required."); } Cursor = Cursors.WaitCursor; // File loading _CurrentVolumeEntry = new Xmb.VolumeEntry(); _LoadXmb(fileTxt.Text); // Updates info labels _UpdateXmbInfo(); _UpdateInstructions(); } catch (Exception e) { _Log.Error(FailureHandler.GetStackTrace(e)); MessageBox.Show(this, e.Message); } finally { Cursor = Cursors.Default; } }
public void WithMessagePassTest() { string msg = "t2fdres4"; new ExceptionAssertion(FailureHandler.Object, new Exception(msg)).WithMessage(msg); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Never()); }
private void HandleFailure(FailureHandler handler, SocketError error) { if (handler != null) { handler(error); } }
public DelegateTask(InitializationHandler initialize, UpdateHandler update = null, SuccessHandler onSuccess = null, FailureHandler onFailure = null) { this.initialize = initialize; this.update = update ?? (() => true); /* * if (update != null) * this.update = update; * else * { * this.update = () => true; // = > * * this.update = () => * { * return true; * }; * * // this is the same as * * bool UpdateMethod() * { * return true; * } * * this.update = UpdateMethod; * }*/ this.onSuccess = onSuccess; this.onFailure = onFailure; }
public void GetStackTraceTest() { Exception ex = new Exception(); string actual = FailureHandler.GetStackTrace(ex); Assert.IsFalse(string.IsNullOrEmpty(actual)); }
private void extractAllButton_Click(object sender, EventArgs e) { if (_Bank != null) { try { // All items selected contentsLst.SelectedIndices.Clear(); for (int i = 0; i < contentsLst.Items.Count; i++) { contentsLst.SelectedIndices.Add(i); } _ExtractSelectedFiles(); MessageBox.Show(this, "Unpack Everything Succeeded!"); } catch (Exception ex) { _Log.Error(FailureHandler.GetStackTrace(ex)); MessageBox.Show(this, ex.Message); } } }
public DelegateTask(InitializationHandler initialize, UpdateHandler update = null, SuccessHandler onSuccess = null, FailureHandler onFailure = null) { this.initialize = initialize; this.update = update ?? (() => true); if (update != null) { this.update = update; } else { this.update = () => true; // = > this.update = () => { return(true); }; // this is the same as bool UpdateMethod() { return(true); } this.update = UpdateMethod; } this.onSuccess = onSuccess; this.onFailure = onFailure; }
public void WithNoInnerExceptionFailTest() { new ExceptionAssertion( FailureHandler.Object, new Exception(string.Empty, new Exception())).WithNoInnerException(); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Once()); }
public void WithMessageFailTest() { string msg = "4356543rf"; new ExceptionAssertion(FailureHandler.Object, new Exception()).WithMessage(msg); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Once()); }
public DelegateTask(InitializationHandler initialize, UpdateHandler update = null, SuccessHandler onSuccess = null, FailureHandler onFailure = null) { this.initialize = initialize; this.update = update ?? (() => true); this.onSuccess = onSuccess; this.onFailure = onFailure; }
public void HandleTest() { const string appName = "TEST_APP"; Exception ex = new Exception(); FailureHandler.Handle(appName, ex); // Should display a dialog box with exception stack trace in it... }
public XYZ GetReferenceDirection(Reference ref1, Document doc) // returns the direction perpendicular to reference // returns XYZ.Zero on error; { XYZ res = XYZ.Zero; XYZ workPlaneNormal = doc.ActiveView.SketchPlane.GetPlane().Normal; if (ref1.ElementId == ElementId.InvalidElementId) { return(res); } Element elem = doc.GetElement(ref1.ElementId); if (elem == null) { return(res); } if (ref1.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_SURFACE || ref1.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_LINEAR) { // make a dimension to a point for direction XYZ bEnd = new XYZ(10, 10, 10); ReferenceArray refArr = new ReferenceArray(); refArr.Append(ref1); Dimension dim = null; using (Transaction t = new Transaction(doc, "test")) { FailureHandlingOptions failureHandlingOptions = t.GetFailureHandlingOptions(); FailureHandler failureHandler = new FailureHandler(); failureHandlingOptions.SetFailuresPreprocessor(failureHandler); failureHandlingOptions.SetClearAfterRollback(true); t.SetFailureHandlingOptions(failureHandlingOptions); t.Start(); using (SubTransaction st = new SubTransaction(doc)) { st.Start(); ReferencePlane refPlane = doc.Create.NewReferencePlane(XYZ.Zero, bEnd, bEnd.CrossProduct(XYZ.BasisZ).Normalize(), doc.ActiveView); ModelCurve mc = doc.Create.NewModelCurve(Line.CreateBound(XYZ.Zero, new XYZ(10, 10, 10)), SketchPlane.Create(doc, refPlane.Id)); refArr.Append(mc.GeometryCurve.GetEndPointReference(0)); dim = doc.Create.NewDimension(doc.ActiveView, Line.CreateBound(XYZ.Zero, new XYZ(10, 0, 0)), refArr); ElementTransformUtils.MoveElement(doc, dim.Id, new XYZ(0, 0.1, 0)); st.Commit(); } if (dim != null) { Curve cv = dim.Curve; cv.MakeBound(0, 1); XYZ pt1 = cv.GetEndPoint(0); XYZ pt2 = cv.GetEndPoint(1); res = pt2.Subtract(pt1).Normalize(); } t.RollBack(); } } return(res); }
public void WithInnerExceptionSpecificNoneFailTest() { ExceptionAssertion assertion = new ExceptionAssertion( FailureHandler.Object, new Exception(string.Empty)).WithInnerException <ArgumentException>(); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Once()); Assert.Null(assertion); }
public void WithInnerExceptionSpecificPassTest() { ArgumentException inner = new ArgumentException(string.Empty); ExceptionAssertion assertion = new ExceptionAssertion( FailureHandler.Object, new Exception(string.Empty, inner)).WithInnerException <ArgumentException>(); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Never()); Assert.Same(inner, assertion.Target); }
private void repackBtn_Click(object sender, EventArgs ea) { if (_Bank != null) { folderBrowserDlg.Description = "Select a directory to repack..."; DialogResult dr = folderBrowserDlg.ShowDialog(this); if (dr == DialogResult.OK) { string bnkDir = folderBrowserDlg.SelectedPath; string[] splittedPath = bnkDir.Split('\\'); string bnkDefaultName = splittedPath[splittedPath.Length - 1]; // Target BNK selection saveFileDialog.Filter = "TDU banks (*.bnk)|*.bnk"; saveFileDialog.Title = "Repack to BNK file..."; saveFileDialog.FileName = bnkDefaultName; dr = saveFileDialog.ShowDialog(this); if (dr == DialogResult.OK) { try { Cursor = Cursors.WaitCursor; // Updates Bnk contents _Bank.Repack(bnkDir); // Commit to disk _Bank.SaveAs(saveFileDialog.FileName); // Reloads current file _Bank.Read(); MessageBox.Show(this, "Repack Succeeded!"); } catch (Exception e) { _Log.Error(FailureHandler.GetStackTrace(e)); MessageBox.Show(this, e.Message); } finally { Cursor = Cursors.Default; } } } } }
public void HandleTest2() { // Failure report try { new ExceptionGenerator().NullPointer(); } catch (Exception ex) { // Critical exception catched here FailureHandler.Handle("TEST_APP", ex); logger.Error(FailureHandler.GetStackTrace(ex)); } }
public static Task ChainFailureHandler(this Task task, FailureHandler failure, Action complete = null) { // create a handler that will raise an exception if an operation fails... return task.ContinueWith((t) => { // create a fatal error bucket... ErrorBucket fatal = ErrorBucket.CreateFatalBucket(t.Exception); failure(task, fatal); // completed? if (complete != null) complete(); }, TaskContinuationOptions.OnlyOnFaulted); }
private void openDirBtn_Click(object sender, EventArgs ea) { if (!string.IsNullOrEmpty(wDirTxt.Text)) { try { Process.Start(wDirTxt.Text); } catch (Exception e) { _Log.Error(FailureHandler.GetStackTrace(e)); MessageBox.Show(this, e.Message); } } }
public static Task ChainFailureHandler(this Task task, FailureHandler failure, Action complete = null) { // create a handler that will raise an exception if an operation fails... return(task.ContinueWith((t) => { // create a fatal error bucket... ErrorBucket fatal = ErrorBucket.CreateFatalBucket(t.Exception); failure(task, fatal); // completed? if (complete != null) { complete(); } }, TaskContinuationOptions.OnlyOnFaulted)); }
/// <summary> /// See docs in <see cref="SoomlaProfile.GetLeaderboards"/> /// </summary> public void GetLeaderboards(SocialPageDataSuccess <Leaderboard> success, FailureHandler fail) { var leaderboardJson = new JSONObject(); leaderboardJson.AddField(PJSONConsts.UP_IDENTIFIER, "main"); leaderboardJson.AddField(PJSONConsts.UP_PROVIDER, Provider.FACEBOOK.ToString()); var leaderboard = new Leaderboard(leaderboardJson); var pageData = new SocialPageData <Leaderboard>(); pageData.HasMore = false; pageData.PageNumber = 1; pageData.PageData = new List <Leaderboard>() { leaderboard }; success(pageData); }
private void dumpButton_Click(object sender, EventArgs e) { if (_Bank != null) { try { Cursor = Cursors.WaitCursor; _Bank.Dump(); MessageBox.Show(this, "BNK now dumped. Have a look at corresponding log file (DjeLib-dump.log)."); } catch (Exception ex) { _Log.Error(FailureHandler.GetStackTrace(ex)); MessageBox.Show(this, ex.Message); } finally { Cursor = Cursors.Default; } } }
private void extractBtn_Click(object sender, EventArgs ea) { if (_Bank != null) { try { if (contentsLst.SelectedIndices.Count == 0) { throw new Exception("At least 1 packed file must be selected for extraction."); } _ExtractSelectedFiles(); MessageBox.Show(this, "Unpack Succeeded!"); } catch (Exception e) { _Log.Error(FailureHandler.GetStackTrace(e)); MessageBox.Show(this, e.Message); } } }
public void ContainsPassTest() { StringAssertion.Contains("t"); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Never()); }
/// <summary> /// See docs in <see cref="SoomlaProfile.GetContacts"/> /// </summary> public override void GetContacts(bool fromStart, SocialPageDataSuccess<UserProfile> success, FailureHandler fail) { }
public void DoesNotContainFailTest() { StringAssertion.DoesNotContain("t"); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Once()); }
/// <summary> /// Called when an error occur /// </summary> /// <param name="e"></param> protected void OnFailureEvent(FailureEventArgs e) { FailureHandler?.Invoke(this, e); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { string getPath = Path.Combine(startPath, "CAD_REVIT_DATA"); revitDoc = commandData.Application.ActiveUIDocument.Document; uidoc = commandData.Application.ActiveUIDocument; ElementId ele = null; Selection selection = uidoc.Selection; ICollection <ElementId> element = selection.GetElementIds(); foreach (ElementId eleID in element) { ele = eleID; break; } var FT2 = new FilteredElementCollector(revitDoc) .OfClass(typeof(FloorType)).GetElementIterator(); FloorType FT = new FilteredElementCollector(revitDoc) .OfClass(typeof(FloorType)) .First <Element>( e => e.Name.Equals("160mm 混凝土與 50mm 金屬板")) as FloorType; Transaction transaction = new Transaction(revitDoc); FailureHandlingOptions failureHandlingOptions = transaction.GetFailureHandlingOptions(); FailureHandler failureHandler = new FailureHandler(); failureHandlingOptions.SetFailuresPreprocessor(failureHandler); failureHandlingOptions.SetClearAfterRollback(false); transaction.SetFailureHandlingOptions(failureHandlingOptions); transaction.Start("Transaction Name"); // Do something here that causes the error List <string> Height = new List <string>(); List <XYZ> Data = LoadTest(ref Height, Path.Combine(getPath, "final.txt")); int kk = 0; foreach (var xyz in Data) { CreateFloor(xyz.X, xyz.Y, double.Parse(Height[kk]), xyz.Z, FT, ele); kk = kk + 1; } transaction.Commit(); // The following is just illustrative. // In reality we would collect the errors // to show later. //if (failureHandler.ErrorMessage != "") //{ // System.Windows.Forms.MessageBox.Show( // failureHandler.ErrorSeverity + " || " // + failureHandler.ErrorMessage); //} return(Result.Succeeded); }
public override void ReportScore(Leaderboard owner, int value, SingleObjectSuccess<Score> success, FailureHandler fail) { }
public override void GetScores(Leaderboard owner, bool fromStart, SocialPageDataSuccess<Score> success, FailureHandler fail) { }
public void IsNotEqualToIgnoringCaseFailTest() { StringAssertion.IsNotEqualToIgnoringCase("ThrehteRj"); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Once()); }
public void SubmitScore(Leaderboard targetLeaderboard, int value, SingleObjectSuccess<Score> success, FailureHandler fail) {}
public override void GetLeaderboards(SocialPageDataSuccess<Leaderboard> success, FailureHandler fail) { }
public void HasAtMostSizeFailTest() { new StringAssertion(FailureHandler.Object, "ab").HasAtMostSize(1); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.AtLeastOnce()); }
public void ContainsFailTest() { StringAssertion.Contains("T"); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Once()); }
public void DoesNotContainPassTest() { StringAssertion.DoesNotContain("T"); FailureHandler.Verify(x => x.Fail(It.IsAny <string>()), Times.Never()); }