Jump to content
MakeWebGames

Dealing with errors


The Spirit

Recommended Posts

Whats your prefered way of dealing errors and in your opinion what way do you think is best practise?

If you use both when do you use each?

trigger_error() or throw new exception() or a custom error handler

At the moment I deal with errors such as database or file handling errors through exceptions and user generator errors with a custom error handler

A discussion on this topic may be interesting

Edited by The Spirit
Link to comment
Share on other sites

For me, it depends.

On dev/test systems, I let the errors flow by PHPs native error handler (verbose error reporting), so I can fix those errors - which are usually silly mistakes.

On live, it depends what logic is talking place. For example;

  • Connecting to a database - try/catch; send header response 500.
  • Updating a row - try/catch; send header response 400/500/dependant on other variables.
  • Syntax error - Custom error handler
  • Debugging live - trigger_error/file_put_contents
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...