BotreamDocs Website Türkçe v0.1.1

Error Handling commands

try · retry · onerror · throw

try Try

Error handling block. The catch section runs when a command fails (catch --error:err puts the details in $err$); the finally section always runs afterwards, error or not (e.g. to close a browser or a workbook).

Block command: try … endtry with catch, finally.

Clause catch

ParameterValueDefaultDescription
--errorvariable nameVariable that receives the error as a record: Message, Type, CommandLine, CommandType, Timestamp (e.g. --error:err, then $err.Message$)
--errormessagevariable nameVariable that receives only the error message
--errorlinevariable nameVariable that receives only the failing line number
--errortypeone of business, systemHandle only errors of this type; the other type passes on to an outer catch. Every error when empty

Clause finally

No parameters.

Examples

try
    browser --action:open --url:"https://portal.example.com" --output:web
    capture --browser:$web$ --action:click --dompath:"//button[@id='submit']"
catch --error:err
    log --message:"Error occurred: $err.Message$" --level:error
    mail --to:"admin@company.com" --subject:"RPA Error" --body:$err.Message$
finally
    browser --browser:$web$ --action:close
endtry
try
    if --condition:"$total$ <= 0"
        throw --message:"Invoice $no$ has no total"
    endif
catch --error:err
    log --message:$err.Message$ --level:error
    throw
endtry

retry Retry

Runs the enclosed commands again when one of them fails, up to --times attempts in all; with --until, also while that condition is false after them. After the last attempt the error goes on as usual (an enclosing try/catch handles it). Business errors (throw --type:business) are not retried.

Block command: retry … endretry.

Parameters

ParameterValueDefaultDescription
--timesnumber3Attempts in all, the first one included (3 = the first run and up to 2 more)
--intervalnumber1Seconds to wait before the next attempt
--untilconditionAlso try again while this condition is false after the commands ran, e.g. $status$ = "done" (written like if --condition)

Examples

retry --times:3 --interval:5
    browser --action:open --url:"https://portal.example.com" --output:web
    capture --browser:$web$ --action:click --dompath:"//button[@id='login']"
endretry
retry --times:10 --interval:30 --until:"$status$ = Ready"
    restapi --action:get --url:"https://api.example.com/jobs/$jobId$" --output:job
    set --name:status --value:$job.Json.status$
endretry

onerror Onerror

Task error handler: runs only when an error that no catch handled is about to fail the task (after the failure screenshot is taken), with the error in --error; then the run fails (or ends as completed with --then:complete). One per task, on the main level, usually at the end. Stopping the task does not run it.

Block command: onerror … endonerror.

Parameters

ParameterValueDefaultDescription
--errorvariable nameerrorVariable that receives the error as a record: Message, Type, CommandLine, CommandType, Timestamp (e.g. $error.Message$)
--thenone of fail, completefailAfter the handler: fail - the run ends as failed with the original error; complete - the error counts as handled and the run ends as completed (with a warning in the log)

Examples

onerror --error:err --then:fail
    log --message:"Failed at line $err.CommandLine$ ($err.CommandType$): $err.Message$" --level:error
    screenshot --file:"C:\Botream\Errors\$System.ExecutionId$.png" --onerror:continue
    mail --action:send --smtp:smtp.company.com --port:587 --from:robot@company.com --to:support@company.com --subject:"Robot failed: $System.TaskName$" --body:$err.Message$ --onerror:continue
    queue --action:fail --item:$item$ --reason:$err.Message$ --onerror:continue
    window --action:close --window:$erp$ --onerror:continue
endonerror

throw Throw

Raises an error: the nearest catch handles it (its --error variable holds the message), otherwise the task fails. Inside a catch section, without --message it passes the caught error on.

Parameters

ParameterValueDefaultDescription
--messagetextError message, e.g. "Invoice $no$ has no total"; inside catch, empty re-throws the caught error
--typeone of business, systembusinessbusiness: a rule of the process is broken (bad data, missing approval) - never retried, the item is skipped. system: the application or network failed - retried like other technical errors
Botream 0.1.1 · Generated 2026-10-14