previous |
start |
next
Error Codes
- Traditional approach to error handling: method returns error
code
- Example: JOptionPane.showInputDialog returns
null if user hits Cancel
- Problem: Calling method may forget to check for error code
- Problem: Calling method may not know how to fix error--then it
needs to return an error code
- Symptom: Programming for success
x.doSomething()
is replaced by programming for failure
if (!x.doSomething()) return false;
previous |
start |
next