~/talk

Leveraging Typed Exceptions for Cleaner Error Handling

Talkat Dutch PHP Conference 2019 · 2019-06-06..06-08· [php, software-architecture]
slides:none on file

Argues for replacing nulls and magic numbers with typed exceptions in PHP, showing concrete code: Doctrine's getSingleResult throws ORM exceptions that are caught and translated into a UserNotFoundException carrying the user ID, PHPUnit tests assert the exception, and controller/service layers shrink from nested checks to single-line calls. Demonstrates exception hierarchies, multi-catch (pipes), and sanitizing message input, claims this reduces lines of code, decouples signaling from handling, and makes APIs less confusing for consumers.

AI-written summary · about

  1. 0:00Intro
  2. 0:54Validations: Painful
  3. 2:51Validations: Graceful
  4. 4:38Get Products for User
  5. 5:05Possible Stack
  6. 6:43getUserById(int Suserld): User
  7. 9:48Products Service: Alternative
  8. 12:16ProductsController: Option 1
  9. 12:45ProductsController: Option 2
  10. 13:44Impacts
  11. 15:34THE KEY IS THAT.
  12. 16:08UserNotFoundException
  13. 17:08Exceptions Flow
  14. 18:14UserRepository
  15. 18:27Simplifying Products Service
  16. 19:00Simplifying ProductsController
  17. 19:29Benefits of Exceptions
  18. 21:06Exceptions Best Practices
  19. 24:57ORM::getSingleResult
  20. 27:43Polymorphic Exceptions
  21. 30:07Catching Exceptions with "I"
  22. 30:52Exceptions & PHPUnit
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.