Forum Discussion

ivan_weng's avatar
ivan_weng
Occasional Visitor
5 years ago

Can't catch exceptions

error message is "The text was rejected."

 

The control reported that the text is invalid due to the following reason: "Reserved word can not be used".

Tested object:
Aliases.DIADesigner.HwndSource_MainWindowView.MainWindowView.ladderCanvas.ObjSymbolEditor
(Sys.Process("DIADesigner").WPFObject("HwndSource: MainWindowView", "DIADesigner - Adv. - Project1").WPFObject("MainWindowView", "DIADesigner - Adv. - Project1", 1).WPFObject("Grid", "", 1).WPFObject("Grid", "", 1).WPFObject("PART_ContentOffset").WPFObject("Grid", "", 1).WPFObject("PART_ContainerContent").WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 1).WPFObject("ShellView", "", 1).WPFObject("Grid", "", 1).WPFObject("DockPanel", "", 1).WPFObject("barManager").WPFObject("DockPanel", "", 1).WPFObject("dockManager").WPFObject("Root").WPFObject("MainHost").WPFObject("TopHost").WPFObject("CenterHost").WPFObject("DocumentHost").WPFObject("FastRenderPanelContentControl", "", 1).WPFObject("DevDocumentPanelEx", "", 1).WPFObject("LayoutPanelContentPresenter", "", 1).WPFObject("LadderView", "", 1).WPFObject("Grid", "", 1).WPFObject("ContentControl", "", 2).WPFObject("LadderEditorView", "", 1).WPFObject("gd").WPFObject("ContentControl", "", 1).WPFObject("LadderCanvasView", "", 1).WPFObject("DockPanel", "", 1).WPFObject("CanvasScroll").WPFObject("ladderCanvas").WPFObject("ObjSymbolEditor", "", 1))
 
my code as below:
try:
  mainWindowView = Aliases.DIADesigner.HwndSource_MainWindowView.MainWindowView
  mainWindowView.BarContainerControl2.DXImage.Click(3, 7)
  mainWindowView.barContainerControl.DXImage.Click(10, 15)
  scrollViewer = mainWindowView.CanvasScroll
  scrollViewer.VScroll.Pos = 0
  scrollViewer.HScroll.Pos = 0
  ladderCanvasVM = mainWindowView.ladderCanvas
  ladderCanvasVM.Click(104, 40)
  ladderCanvasVM.ObjSymbolEditor.SetText("")  Aliases.DIADesigner.HwndSource_MainWindowView.MainWindowView.ladderCanvas.IntelliSenseListBox.WPFObject("Li  stBoxItem", "", 1).Click()
except Exception as e:
  Log.Error(str(e))
 
How can i do?  thanks a lot.
  • Hi,

     

    try/catch are the means of the programming language to handle runtime errors like division by zero, memory access at 0x0 and the like. Also, these runtime errors may be simulated with the help of the throw.

     

    Your code does not fail because of runtime problem: control exists, text can be entered into control and control can be clicked. Thus, no reason to throw an exception from the operating system point of view.

     

    What you need to do to handle your case is to check whether or not the error message exists and proceed appropriately.

     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    try/catch are the means of the programming language to handle runtime errors like division by zero, memory access at 0x0 and the like. Also, these runtime errors may be simulated with the help of the throw.

     

    Your code does not fail because of runtime problem: control exists, text can be entered into control and control can be clicked. Thus, no reason to throw an exception from the operating system point of view.

     

    What you need to do to handle your case is to check whether or not the error message exists and proceed appropriately.