Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Atef95's avatar

Try/Catch blocks usage

Hey guys

Im confused about the real usage of try/catch blocks..

I've seen many answers that are different and not totally convincing for me..

Some people say it should be implemented whenever there is an exception ( sth like server down..etc)

For example :

If I'm updating a user and checking on its existence ..

what if just before executing the update() method someone has deleted that user ?

same for delete() method..

do I need try/catch for these scenarios ?

I feel I need to wrap up all my functions with them..

Thank you in advance...

0 likes
1 reply

Please or to participate in this conversation.