EECS 280 Lecture 21: Exceptions

43 views2 pages

Document Summary

Our goal is to separate error detection from error correction. The easiest way to deal with an error is to do nothing. The good thing about this is that it"s easy to code, but it can lead to bugs. Another option is to return a special value if there"s an error. This is also easy to implement, but some special values can con icts with normal values; this could lead to bugs. Another is that we get an error code as output parameter or as an input parameter. It"s easy to implement and it handles errors in the same code that you handle normal cases (this is a pro and a con). Code that corrects an error goes in a catch block, code that will test if there is an error goes in a try block. This can only be done in functions that throw exceptions (like atoi() and stoi()). If no error is detected, catch code is not executed.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions