Leveraging Typed Exceptions for Cleaner Error Handling

 5 years ago 5,751 views
Presented by Chris Holland

July 18, 2019

Harnessing Errors & Edge-Cases with Ease & Elegance.

Imagine handling error conditions and unexpected edge-cases with code that is easier to read, maintain & extend.

The temptation is real.

We create methods that return an array of objects, or "false" if nothing was found. Or "null". We might further "signal" unexpected results or error-conditions with integer values.

It then becomes the responsibility of consumers of these methods, to properly interpret what "false", "null", or "-500" mean. As a result, we produce code that is difficult to read, maintain and extend.

Exceptions are seldom leveraged, and most often thought of as objects thrown by some frameworks for instrumentation. When properly leveraged, they however offer an opportunity to manage unexpected and edge-case behavior at various layers of our applications, with elegant control flows.

By leveraging your language's Exceptions alongside its "Type System", we can create elegant, flexible and advanced handling of Error conditions, which will promote code that is easier to work with.

What you'll learn from this talk:
use-cases for leveraging exceptions, recognizing patterns where they would be a better fit
how exceptions allow us to signal errors with less code
how exceptions allow us to handle errors with less code
how exceptions can help us build more robust systems with far less technical debt

About Chris Holland
Chris Holland leads a small Software Engineering Team at an HR company. Throughout a career spanning more than 20 years, Chris has held Sr. Engineering and Leadership roles for small and large successful publicly-traded companies such as EarthLink and Internet Brands, serving business models across Content, Commerce, Travel & Finance on a wide variety of technology stacks including PHP/LAMP, Java/J2EE and C#/.Net, catering to audiences over 100 million monthly visitors.

Chris is also a contributor to NomadPHP and php[architect] magazine, and has been published in CIOReview.

SPONSORS

SPONSORS

PHP Tutorials and Videos
No comments found.

SPONSORS

PHP Tutorials and Videos