202017 PHPS Exception Handling
prev
BRE
Good Design
Exceptions should always be used as an addon and not as the base for Error Handling. This
Means, you won't get around coding carefully and checking for error conditions wherever you can.
T usually call this whole thing ‘pessimistic programming’ (starts with customer-quality-standards
vs developers-quality-standards, goes via agile methods and ends in pessimistic view of code and
possible events
function eove(Stype)
t
11 no (valid) paraneter? exit
Af(IStype) return false;
11. important pre-condition fails
AF(ISthis-risValidtove(astype))
return false;
11 Snportant step fails,
Lf(isthis-startaction())
‘theow! new Failedactionexception (8s
M1 ok
return true;
Using this approach, you'll save some nested blocks (like deep nested 'if') and have shorter,
snappiert code, handling errors where they occur. You'll get a feeling on when to use Exceptions,
and when to use standard handling.
Questions?
Feel free to contact andreas@php.net if you have further questions concerning exceptions
prev
fle:tiDSourcocodesiWebiPHP/amp%420stack%s20works/TigrIT-Frfiyl2end%s200n%20Kausarishoob$420i_uplZ
JOOPHoxception/out html wt