Suppose I have the following code:
void foo() { /* ... */ try { bar(param1); } catch (MyException e) { /* ??? */ } } void bar(Object param1) throws MyException { /* ... */ try { baz(param2); } catch (MyException e) { /* ??? */ } } void baz(Object param2) throws MyException { /* ... */ if (itsAllATerribleMistakeOhNo) { /* ??? */ throw new MyException("oops, error."); } }
I am wondering where and how I should report the error.
Another complication is that the error below may not be considered an error when you look at it from above (for example, searching for something in the database fails, maybe you weren’t sure), so I could choose logger.WARN()instead logger.ERROR().
logger.WARN()
logger.ERROR()
, 3 (, ) - , , . 2x2:
?
: / , , .
, :
1) , . , , API , , . API , API .
2) . , , (SQLException), , , , .
SQLException
3) Re-Throwing exceptions: API , , , .
4) . , .
UPDATE: Java
, . , . , .
foo() ( IP-, , ).
foo()
/ . catch throwable, , , , , , - .
catch throwable
. , ApplicationException, (String) (, Enum). , , .
ApplicationException
, . , , : - ( , -, () ). , .
:
, . . - , , , , .
, , , , catch, - , . , .