Leveraging Typed Exceptions for Cleaner Error Handling

Chris Holland (15.Nov.2018 at 10:30, 50 min)
Talk at php[world] 2018 (English - US)

Rating: 5 of 5

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. However, when properly leveraged, they 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.

Who are you?

Claim talk

Talk claims have been moved to the new Joind.in site.

Please login to the new site to claim your talk

Want to comment on this talk? Log in or create a new account or comment anonymously

Write a comment

Please note: you are not logged in and will be posting anonymously!
= one plus six


Rating: 5 of 5

16.Nov.2018 at 12:03 by Ben Rosenbach (1 comments) via Web2 LIVE

Lots of great stuff I'll be immediately using in my code.

Rating: 5 of 5

20.Nov.2018 at 10:25 by Kenneth Huether (4 comments) via Web2 LIVE

Learned some good stuff that I'll be refactoring into old code and taking advantage of in new code. Thanks!

© Joind.in 2019