~/talk

Leveraging Typed Exceptions for Cleaner Error Handling

Talkat phpday 2020 · on Tuesday, 2020-09-08· [php, developer-experience]
slides:none on file

Argues that typed exceptions simplify layered PHP code by replacing sentinel returns with real error types, showing Doctrine’s getSingleResult throwing NoResultException or NonUniqueResultException and the creation of a UserWasNotFound exception that bubbles up or is caught and translated, simplifying a product service and controller. Demonstrates PHPUnit’s expectException for tests, uses ben ramsey UUIDs to generate bogus IDs, and recommends catching ORM exceptions, embedding helpful messages, and preferring many specific exception classes over numeric status codes.

AI-written summary · about

  1. 0:00Start
  2. 4:27Validation Methods
  3. 7:53Layered Architectures
  4. 9:51Error Signaling
  5. 11:38Layered Architecture with Exceptions
  6. 13:41Failure Modes
  7. 13:51The User Could Not Be Found
  8. 20:50Inconsistent Return Types
  9. 28:23The Exception Flow
  10. 30:46Better Practices for Exceptions
  11. 31:37Custom Exception Classes
  12. 33:17Catching Polymorphic Exceptions
  13. 38:49Pipes
  14. 40:37Live Coding
  15. 46:06Takeaways
~/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.