Skip to content

Avoid Catching Generic CX_ROOT (Catch Specific Exceptions) ​

WarningSecurity & Robustness#EC NO_CATCH_ROOTRemote Enabled

Overview ​

Catch specific exceptions instead of generic cx_root.

ATC Finding Message: Avoid generic CATCH cx_root; catch specific exception classes instead

Rationale ​

Catching the root exception class CX_ROOT indiscriminately traps all exceptions, including catastrophic system resource exhaustion (CX_SY_RESOURCE_FAILURE), database disconnections, and critical assertion failures. Catching CX_ROOT without re-raising creates the "Black Hole Exception Antipattern", masking fatal bugs and allowing corrupted processes to continue running.

Best Practice: Always catch specific, expected exception classes (CATCH zcx_order_not_found zcx_pricing_failed).

Non-Compliant ​

abap
" Anti-pattern: Swallows fatal database disconnection and memory errors silently
TRY.
    process_order( ).
  CATCH cx_root.
    " Swallowed! Program continues with corrupt state.
ENDTRY.

Compliant ​

abap
" Clean ABAP: Catch specific anticipated domain exceptions only
TRY.
    process_order( ).
  CATCH zcx_invalid_order_status INTO DATA(lx_status).
    mo_logger->warn( lx_status->get_text( ) ).
  CATCH zcx_credit_limit_exceeded INTO DATA(lx_credit).
    mo_order_queue->hold( is_order ).
ENDTRY.

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC NO_CATCH_ROOT

" SAP CI_ prefix format:
... "#EC CI_NO_CATCH_ROOT

Technical Details ​

Released under the MIT License.