Throw CX_STATIC_CHECK for manageable exceptions
If an exception can be expected to occur and be reasonably handled by the receiver,
throw a checked exception inheriting from CX_STATIC_CHECK: failing user input validation,
missing resource for which there are fallbacks, etc.
CLASS cx_file_not_found DEFINITION INHERITING FROM cx_static_check.
METHODS read_file
IMPORTING
file_name_enterd_by_user TYPE string
RAISING
cx_file_not_found.This exception type must be given in method signatures and must be caught or forwarded to avoid syntax errors. It is therefore plain to see for the consumer and ensures that (s)he won’t be surprised by an unexpected exception and will take care of reacting to the error situation.
This is in sync with the ABAP Programming Guidelines but contradicts Robert C. Martin’s Clean Code, which recommends to prefer unchecked exceptions; Exceptions explains why.