Skip to content

Instantly share code, notes, and snippets.

@weiserman
Created February 2, 2022 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weiserman/a813508d03b629726e5f2ca66080a0c5 to your computer and use it in GitHub Desktop.
Save weiserman/a813508d03b629726e5f2ca66080a0c5 to your computer and use it in GitHub Desktop.
Consumer Robot syntax
*** Settings ***
Library RPA.Robocorp.WorkItems
Library RPA.Tables
Library RPA.JSON
Library Collections
*** Tasks ***
Consume Items
[Documentation] Cycle through the quote items
For Each Input Work Item Handle Quote
*** Keywords ***
Handle Quote
[Documentation] Error handling around one work item
${payload}= Get Work Item Payload
${Quote Handled}= Run Keyword And Return Status
... Action For Item ${payload}
IF ${Quote Handled}
Release Input Work Item DONE
ELSE
# Giving a good error message here means that data related errors can be fixed faster in Control Room
${error_message}= Set Variable
... Failed to handle item for: ${payload}.
Log ${error_message} level=ERROR
Release Input Work Item FAILED exception_type=BUSINESS message=${error_message}
END
*** Keywords ***
Action For Item
[Documentation]
... Simulates handling of one work item that fails 1/5 times to highlight BUSINESS exception handling.
[Arguments] ${payload}
${Item Action OK}= Evaluate random.randint(1, 5)
IF ${Item Action OK} != 1
Log Did a thing item for: ${payload}
ELSE
Fail Failed to handle item for: ${payload}.
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment