Skip to content

Avoid CATCH Blocks That Only Re-raise the Same Exception ​

WarningAnti-Patterns & Bad Practices#EC NO_CATCH_RERAISERemote Enabled

Overview ​

Detect CATCH blocks that only re-raise the same exception.

ATC Finding Message: CATCH block only re-raises the same exception; remove it

Rationale ​

A CATCH block whose only statement re-raises the identical exception type adds no value: the handler is logically transparent and only adds noise, stack depth and maintenance cost. Either remove the CATCH clause and let the exception propagate, or enrich it with context (previous, a domain exception, or message text). This rule only reports blocks that consist of exactly one bare re-raise statement.

Non-Compliant ​

abap
TRY.
    lo_service->run( ).
  CATCH zcx_service_error.
    RAISE EXCEPTION TYPE zcx_service_error.
ENDTRY.

Compliant ​

abap
TRY.
    lo_service->run( ).
  CATCH zcx_service_error INTO lx_error.
    RAISE EXCEPTION NEW zcx_service_error( previous = lx_error ).
ENDTRY.

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.