2007 Dec 19 5:56 AM
question : is it necessary for caller to catch all the exceptions and re-raise them if the caller cannot handle it?
Plan A. code brief
*definition
METHODS meth_a
RAISING ex_b.
METHODS meth_c
RASING ex_d.
*implementation
METHOD c
TRY.
CALL METHOD me->meth_a.
CATCH ex_b into l_ex_b.
"suppose meth_c cannot handle the situation, just envelope and reraise it
RAISE EXCEPTION TYPE ex_d
EXPORTING
previous = l_ex_b
textid = 'new text id to explain why meth_c failed'
ENDTRY.
ENDMETHOD.
Plan B. code brief
*definition
METHODS meth_a
RAISING ex_b.
METHODS meth_c
RASING ex_b ex_e. " declare 2 exception
*implementation
METHOD c
CALL METHOD me->meth_a.
"....
RAISE EXCEPTION TYPE ex_e. " no relation to ex_b
ENDMETHOD.
the second implementation saves more labor, but I don't know if it will lost some exception-chain information?
is it necessary to do as first implementaion? for each exception handler?
thanks and regards,
2007 Dec 19 6:01 AM
No, its not necessary to catch all exceptions, if the user is sure of not getting them.
But as a good practice to avoid any confusion or unforeseen dumps one should handle all.
Its not just about labor its about delivering a good code.
Regards,
Amit
Edited by: Amit Khare on Dec 19, 2007 6:01 AM
2007 Dec 19 6:01 AM
No, its not necessary to catch all exceptions, if the user is sure of not getting them.
But as a good practice to avoid any confusion or unforeseen dumps one should handle all.
Its not just about labor its about delivering a good code.
Regards,
Amit
Edited by: Amit Khare on Dec 19, 2007 6:01 AM
2007 Dec 19 6:05 AM
2007 Dec 19 6:06 AM