Re: how to stop execute script when a error occur?
You can accomplish the task by enabling the "Stop on error" playback option of your project (right-click the project in the Project Explorer panel, select Edit | Properties from the context menu and select the Playback options group). Please see the "Project Properties - Playback Options" help topic for details.
As for the OnLogError event, you need to use the Runner.Stop method in this event handler to stop the test execution (see the "Runner.Stop" help topic). Please see the "Handling Events With TestComplete" help topic to learn how to create an event handler.