Limit Number of CATCH Clauses per TRY Block
WarningMetrics & Complexity Limits#EC MAX_CATCH_CLAUSESRemote Enabled
Overview
Limit CATCH clauses per TRY block.
ATC Finding Message:
TRY block has too many CATCH clauses; handling too many errors indicates coupling
Rationale
A single TRY block handling an excessive number of distinct exception types indicates high coupling and overly broad responsibilities. Decompose the procedure or catch common superclasses if appropriate.
Non-Compliant
abap
TRY.
execute_workflow( ).
CATCH cx_a. ...
CATCH cx_b. ...
CATCH cx_c. ...
CATCH cx_d. ...
ENDTRY.Compliant
abap
TRY.
execute_workflow( ).
CATCH cx_workflow_error. ...
ENDTRY.Configuration & Thresholds
This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:
| Parameter Name | Data Type | Default Value | Description & Guidance |
|---|---|---|---|
MAX_CATCH_CLAUSES | Integer | 3 | Maximum number of CATCH clauses allowed per TRY block (default: 3) |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC MAX_CATCH_CLAUSES
" SAP CI_ prefix format:
... "#EC CI_MAX_CATCH_CLAUSESRelated Rules
- Avoid Catching Generic CX_ROOT (Catch Specific Exceptions) —
#EC NO_CATCH_ROOT - Prefer Class-Based Exceptions over Classic EXCEPTIONS —
#EC PREF_CLASS_EXC
Technical Details
- Native ATC Class:
ZCL_SKYLINT_MAX_CATCH_CLAUSES - Implementation File: zcl_skylint_max_catch_clauses.clas.abap