Throw exception Version 2 (Java)

Action group: Base actions


Description

This action is intended to force the robot to terminate, since the algorithm should not continue at this step.

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
MessageMessage text to be output to the log fileRobin.String
No

Special conditions of use

None.

Example of use

Task

It is necessary to get the user's answer to the question about program termination.

If the answer suggests that the work should be terminated, print a message to the log and terminate the work. 

Solution

  1. Add a "Question dialog" action.
  2. Add an "If" action.
  3. Add an "Throw exception" action.

Implementation

  1. Open the "Dialogs" action group.
  2. Move the "Question dialog" action to the Studio workspace.
  3. Set the action parameters:
    1. In the "Question dialog" parameter, specify the text: "Stop program operation?" 

  4. Open the "Base actions" action group.

  5. Place an "If" action in the Studio workspace (see the description of the "If (Base actions)" action).

  6. Set the action parameters:
    1. Set the result of the "Question dialog" action in the condition.

    2. Place the "Throw exception" action on the "Yes" branch.

    3. In the "Message" parameter of the "Throw exception" action specify the text: "The user requested to stop the program".





  7. Launch the robot using the "Start" button in the top panel.

  8. Answer "Yes" to the question in the dialog box.

Result

The program was terminated and the message "User requested to stop the program" was displayed in the log.

 

  • Нет меток