Error hiding
From Wikipedia, the free encyclopedia
In computer programming, error hiding (or error swallowing) is the practice of catching an error or exception, and then continuing without logging, processing, or reporting the error to other parts of the software. Handling errors in this manner is considered bad practice[1] and an anti-pattern in computer programming. In languages with exception handling support, this practice is called exception swallowing.
This article may be too technical for most readers to understand. (April 2019) |
This article is written like a personal reflection, personal essay, or argumentative essay that states a Wikipedia editor's personal feelings or presents an original argument about a topic. (April 2019) |
Errors and exceptions have several purposes:
- Help software maintainers track down and understand problems that happen when a user is running the software, when combined with a logging system
- Provide useful information to the user of the software, when combined with meaningful error messages, error codes or error types shown in a UI, as console messages, or as data returned from an API (depending on the type of software and type of user)
- Indicate that normal operation cannot continue, so the software can fall back to alternative ways of performing the required task or abort the operation.
When errors are swallowed, these purposes can't be accomplished. Information about the error is lost, which makes it very hard to track down problems. Depending on how the software is implemented, it can cause unintended side effects that cascade into other errors, destabilizing the system. Without information about the root cause of the problem, it's very hard to figure out what is going wrong or how to fix it.