Abstract
Until this point we have used assert statements to ensure that a condition required by the code to generate correct output is met. For example, we might check that a number that we were going to take the square root of is non-negative, and trip an assertion if this condition were not met. Whilst this approach is very useful as it pinpoints errors, it is rather inflexible as it terminates the code at the instant that an assertion is tripped. We would much rather the code instead made some attempt to fix the problem itself, if that were possible, warned us of the possible effects of the fix if necessary, and then carried on executing. This is possible through the use of exceptions, which are the focus of this chapter.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2012 Springer-Verlag London Limited
About this chapter
Cite this chapter
Pitt-Francis, J., Whiteley, J. (2012). Errors and Exceptions. In: Guide to Scientific Computing in C++. Undergraduate Topics in Computer Science. Springer, London. https://doi.org/10.1007/978-1-4471-2736-9_9
Download citation
DOI: https://doi.org/10.1007/978-1-4471-2736-9_9
Publisher Name: Springer, London
Print ISBN: 978-1-4471-2735-2
Online ISBN: 978-1-4471-2736-9
eBook Packages: Computer ScienceComputer Science (R0)