Skip to content

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 NameData TypeDefault ValueDescription & Guidance
MAX_CATCH_CLAUSESInteger3Maximum 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_CLAUSES

Technical Details ​

Released under the MIT License.