Chapter 20. Error Handling
Introduction
The name programmer for those who spend their time developing web applications is misleading: the vast majority of time one spends programming is actually spent debugging. Whether youâre fixing typos or refactoring chunks of code that are performing poorly in a heavily loaded production environment, odds are youâll spend a large amount of your career debugging and testing, and debugging and testing again. And again, and again, and again.
The raucous party that is a frantic, all-night debugging session was probably omitted from your job descriptionâwho would sign up for that kind of fun? The fact is that errors, bugs, debugging, and testing are a part of the programmerâs life. If you face this head on with good practices and techniques, you can minimize the time you spend debugging and maximize the time you spend on the good stuff.
Unfortunately, many developers donât spend much time building error handling, debugging, and testing skills; donât make the same mistake. If you employ whatâs affectionately known as pessimistic programming, youâll begin to plan for things to go wrongâand your application will be prepared to handle it gracefully during those moments.
This chapter deals with errors: finding the source of errors, determining what was going on when an error occurred, hiding errors from end users, and logging errors so you can conduct informed debugging sessions after the error occurs. Chapter 21 complements this information ...
Get PHP Cookbook, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.