Preserve the Original Exception with PREVIOUS
WarningAnti-Patterns & Bad Practices#EC NO_EXC_CHAINRemote Enabled
Overview
Preserve the original exception with PREVIOUS.
ATC Finding Message:
Converted exception does not follow the PREVIOUS chaining policy
Rationale
When a handler converts an exception into a new one without setting previous, the caller loses the root cause and only sees the outer symptom. Passing the caught exception object through the previous attribute keeps the full chain available in the stack trace and in RAP error logs. The rule inspects RAISE EXCEPTION NEW and RAISE EXCEPTION TYPE inside CATCH ... INTO handlers.
Non-Compliant
abap
TRY.
lo_http->send( ).
CATCH cx_http_error INTO lx_http.
RAISE EXCEPTION NEW zcx_upload_failed( ).
ENDTRY.Compliant
abap
TRY.
lo_http->send( ).
CATCH cx_http_error INTO lx_http.
RAISE EXCEPTION NEW zcx_upload_failed( previous = lx_http ).
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 |
|---|---|---|---|
REQUIRE_PREVIOUS | Boolean | true | Report converted exceptions without PREVIOUS (default); disable to report the opposite style |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_EXC_CHAIN
" SAP CI_ prefix format:
... "#EC CI_NO_EXC_CHAINRelated Rules
- Avoid CATCH Blocks That Only Re-raise the Same Exception —
#EC NO_CATCH_RERAISE - 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_NO_EXC_CHAIN - Implementation File: zcl_skylint_no_exc_chain.clas.abap