CMPSC 32 Lecture Notes - Lecture 12: Errno.H, Call Stack, Side Effect
Document Summary
There is a way down the call stack. Don"t have to test for an error after each line of code. Can write long stretched of code without error-handling. If the current scope has a catch block, it is executed. If it doesn"t, the exception propagates up the call stack until a catch block is found. Use multiple catch blocks to distinguish between exception types try { somethingthatmightfail(); somethingelsesketchy(); tediousanderrorprone(); catch (int i) { // do something with i catch (std::exception& e) { In nested function/method calls, they are unwound from stack. Destructors are called on all local (automatic) values. If there are pointers to external memory, their owner should release them in the destructor. Stop whe(cid:374) the pro(cid:271)le(cid:373) happe(cid:374)s a(cid:374)d do(cid:374)"t (cid:272)o(cid:374)ti(cid:374)ue. Skip as many function nestings (stack) as needed. Return to state of code right before error happened. Can say what kind of error the function might throw void tediousanderrorprone() throw std::exception;