Error handling with BEGIN SEQUENCE and RECOVER
Controls execution interruption and recovery.
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.)
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 NilDisplays 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.
- 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.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.