Error Handling, Exception Management and Recovery
Exception types
Know the distinction between System Exceptions (technical failures - element not found, application crash, timeout) and Business Exceptions (the data or business rule says stop - customer not found, validation failed). This distinction drives everything: System Exceptions are usually retried or recovered; Business Exceptions are usually marked as failed work and not retried. Getting this classification wrong is the most common exam trap.
Blocks, Recover, Resume
A Block stage groups stages so that an exception inside it transfers control to the block's Recover stage rather than crashing the page. The Recover stage handles the exception (log it, clean up, decide to retry or rethrow). Resume returns flow to the block's Resume stage, continuing after the block. Understand that an unhandled exception propagates up the call stack and, in a queue-driven process, ends the case as an exception.
Preserving the original exception
When you catch and rethrow, preserve the original exception detail rather than replacing it with a generic message - otherwise diagnosis becomes impossible. Use the Exception stage to deliberately raise a Business Exception with a clear, data-bearing message.
Recovery patterns
Retry with a bounded attempt count; clean up the application state (close windows, reset to home) before retrying; then escalate. In queue processing, a System Exception typically returns the item to the queue (often with a deferred retry), while a Business Exception marks the item as an exception with a reason. Never build infinite retry loops.
Worked example
Inside a Block, attempt to read the customer record. Recover catches 'element not found', increments a retry counter, and if attempts remain, re-enters the block; otherwise it raises a System Exception so the queue handles it. If the search succeeds but returns zero rows, raise a Business Exception instead.
Traps
Confusing Recover (handles) with Resume (continues), and retrying Business Exceptions.