~/talk

Leveraging Typed Exceptions for Cleaner Error Handling

Talkat PHP fwdays'20 online · 2020-05-30..05-31· [php]
slides:none on file

Demonstrates that replacing nulls and magic return codes with typed exceptions yields flatter, clearer code: catch Doctrine ORM no-result and non-unique-result cases, throw a UserNotFoundException, simplify service and controller layers, and verify behavior with PHPUnit expectException. Uses getSingleResult, custom exception classes and small refactors; tests move from failing on raw ORM exceptions to passing once the custom exception is thrown, removing ad hoc -1/null signaling and reducing cascading error checks.

AI-written summary · about

  1. 0:00Introduction
  2. 1:03The problem with validation
  3. 3:44Introducing exceptions
  4. 5:46Complex error handling case
  5. 14:22Impact of manual error codes
  6. 20:36Exceptions as a solution
  7. 24:23Exception best practices
  8. 28:02Polymorphic exception handling
  9. 33:21Testing and implementation
  10. 40:31Conclusion and Q&A
~/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.