<-- previous rule | overview | next rule -->
Replaces the TYPE section of RAISE EXCEPTION TYPE ... and RAISE SHORTDUMP TYPE ... with a NEW constructor call.
This rule requires a NetWeaver version >= 7.52.
This rule is part of the essential profile, as it is explicitly demanded by the Clean ABAP Styleguide.
- (no options available for this rule)
METHOD replace_raise_type_with_new.
RAISE EXCEPTION TYPE cx_any_exception.
RAISE RESUMABLE EXCEPTION TYPE cx_any_exception.
RAISE EXCEPTION TYPE cx_other_exception
EXPORTING
any_param = any_value
other_param = other_value.
RAISE SHORTDUMP TYPE cx_demo_t100
EXPORTING
textid = cx_demo_t100=>demo
text1 = 'this'
text2 = 'is'
text3 = 'an'
text4 = 'example'.
" NEW is not possible with [USING] MESSAGE
RAISE EXCEPTION TYPE cx_any_exception USING MESSAGE.
ENDMETHOD.
Resulting code:
METHOD replace_raise_type_with_new.
RAISE EXCEPTION NEW cx_any_exception( ).
RAISE RESUMABLE EXCEPTION NEW cx_any_exception( ).
RAISE EXCEPTION NEW cx_other_exception(
any_param = any_value
other_param = other_value ).
RAISE SHORTDUMP NEW cx_demo_t100(
textid = cx_demo_t100=>demo
text1 = 'this'
text2 = 'is'
text3 = 'an'
text4 = 'example' ).
" NEW is not possible with [USING] MESSAGE
RAISE EXCEPTION TYPE cx_any_exception USING MESSAGE.
ENDMETHOD.