Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Error handling with BEGIN SEQUENCE and RECOVER

Controls execution interruption and recovery.

Error handling with BEGIN SEQUENCE and RECOVERAdvPL
01 · OVERVIEW

Overview

BEGIN SEQUENCE delimits instructions; Break transfers to RECOVER and USING receives the supplied expression. This example explicitly breaks with a fictional marker. Redirecting runtime errors requires compatible handling such as ErrorBlock invoking Break; the sequence does not automatically capture every fatal failure. Save/restore an overridden ErrorBlock and avoid RETURN paths skipping cleanup. Flow recovery does not automatically roll back transactions, release locks or close resources; the owner must handle them. (Sources: refs. 1–1.)

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed696()
    Local xError
    Begin Sequence
        // Fictional marker demonstrates transfer without a data error.
        Break("ED696")
    Recover Using xError
        ConOut("Recovery: "+cValToChar(xError))
    End Sequence
Return Nil
Expected result

Displays Recovery: ED696 in the proposed flow. Demonstrates neither fatal-error capture nor rollback. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Do not suppress failures by reporting success. Preserve diagnostics without secrets and test error-path cleanup.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. BEGIN SEQUENCE ... END. Break, Recover Using e ErrorBlock. Accessed on 2026-10-28.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha