Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Exception Handling in PHP
Search
Frank Neff
November 06, 2014
Programming
2
120
Exception Handling in PHP
A lightning Talk about exception handling best practices in PHP for one of our customers
Frank Neff
November 06, 2014
Tweet
Share
More Decks by Frank Neff
See All by Frank Neff
Principles of Object Orientation
frne
0
270
Symfony High Availability in the Cloud
frne
0
510
Symfony 3 [german]
frne
0
420
Solr für Volltext-Suche oder gleich als Datenbank Engine
frne
0
300
Plaing with Neo4j -[:USING]-> PHP
frne
0
400
PHP under the hood
frne
3
210
Other Decks in Programming
See All in Programming
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
140
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
1.3k
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
430
Beyond ORM
77web
11
1.6k
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
300
chibiccをCILに移植した結果 (NGK2025S版)
kekyo
PRO
0
130
ChatGPT とつくる PHP で OS 実装
memory1994
PRO
3
190
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
420
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
630
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.8k
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
0
140
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Automating Front-end Workflow
addyosmani
1366
200k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
960
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
How STYLIGHT went responsive
nonsquared
96
5.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Transcript
try { Exception Handling in PHP } A brief introduction
Exception != Error
– docs.oracle.com “An exception is an event, which occurs during
the execution of a program, that disrupts the normal flow of the program's instructions.”
– php.net/manual “When an exception is thrown, code following the
statement will not be executed, and PHP will attempt to find the first matching catch block. If an exception is not caught, a PHP Fatal Error will be issued with an "Uncaught Exception ..." message”
Application Layers Presentation Business Data NoDatabaseConnectionException NoResultException EmptyResultException InvalidConfigurationException HTTP/404
HTTP/500
Example EVIL!
– Me “Because a DBAL does not know how to
handle an empty result… But the business logic does!”
Done right
Done right
Pass Exceptions through layers
Exceptions
DBAL
Repository
Controller
– OSS Development Wisdom “An API method should always return
an expected result or throw an exception.”
Thanks ;) frankneff.ch - @frank_neff - github.com/frne