Using Exceptions
- Not much wisdom here.
- new/alloc can cause an exception.
- He states that this is rare on 64 bit systems.
- But it is a problem for mobile, embedded, ....
- It might not be reasonable to catch all of these.
- But it might.
- Really hard to clean up.
- If you catch one of these save your state?
- Don't use exceptions as a tool for sloppy programming.
- Don't use exceptions to control logic.
- You see this on line alot.
- This is a bad practice, at least in c++
- Don't use exceptions to clean up bugs in your code.
- Some guidelines
- Use exceptions when the code that finds the error is separate from the code that caused the error
- The vector example is good.
- Don't catch what you can't handle
- Catch an exception as close to the point of error as possible.
- After we get further in OOP, you might want to revisit this chapter.