Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 785689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:55:13+00:00 2026-05-14T20:55:13+00:00

I am working on a PHP framework and am currently designing error handling. Based

  • 0

I am working on a PHP framework and am currently designing error handling. Based on what I have read on SO, I should only use exceptions for, well, exceptional situations. Therefore throwing an exception when an incorrect password is entered is wrong.

Should I avoid using exceptions when I want to return a server error code to the user (eg. 404 Page Not Found)? If so, should I write my own error handling class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:55:14+00:00Added an answer on May 14, 2026 at 8:55 pm

    Your code shouldn’t throw an exception to interact with the user, it should throw the exception to notify a higher level of code that something unrecoverable happened.

    Now, depending on what happened, you may want to respond with a certain HTTP status code. But at that point you’re not throwing exceptions to trigger a server error, you’re catching exceptions and giving the user an appropriate response.

    If the questions is what should happen when an article/blog/item/etc is requested that doesn’t exist — well, if it’s possible for the code responsible for displaying the information to just set the response code, then by all means, don’t use exceptions.

    If you’re using a MVC framework, and your individual controllers can set the response code, then let them.

    And if the topmost exception handler can use a http response code to better present the error message to the user, then let it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Linq-to-XML is a good solution (and even better in VB.NET… May 16, 2026 at 8:44 am
  • Editorial Team
    Editorial Team added an answer To set the auto_increment value to 1533, use: ALTER TABLE… May 16, 2026 at 8:44 am
  • Editorial Team
    Editorial Team added an answer See Plausible Blocks for a port of the blocks runtime… May 16, 2026 at 8:44 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am currently working on a very specialized PHP framework, which might have to
I am currently working on a php framework, which is in some cases structured
Hi I'm currently working on some php - zend framework project on my osx
I'm currently working on my own PHP Framework, and I need some help figuring
I am currently working with the Zend Framework and I use PHPEd as my
I'm creating a PHP web application framework (MVC). I'd rather not use external libraries
Currently I am working with a commercial project with PHP. I think this question
Here's the scene: I'm currently working on my own framework and on a client's
I'm working through Practical Web 2.0 Appications currently and have hit a bit of
I basically am working with an oldschool php cms based site in Russian, one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.