Chapter 6. Error Handling
You will always encounter errors in the real world. How well you handle them shows the quality of your code.
Java has its roots in embedded systems—the software that runs inside specialized devices, such as the handheld computers, cellular phones, and fancy Internet of Things (IoT) toasters. In those applications, it’s especially important that software errors be handled robustly. Most users would agree that it’s unacceptable for their phone to crash on a regular basis—or for their toast (and perhaps their house) to burn because some software failed. Given that we can’t eliminate the possibility of software errors, recognizing and dealing with application-level errors methodically is a good step in the right direction.
Some languages leave the responsibility for handling errors entirely with the programmer. The language itself provides no help in identifying error types and no tools for dealing with them easily. In the C language, for example, functions generally indicate ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access