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 8229063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:40:27+00:00 2026-06-07T16:40:27+00:00

I am working on a pretty large project and have read a lot about

  • 0

I am working on a pretty large project and have read a lot about exception here at stackoverflow and on other websites. The result was, that there is 100% right or wrong. Some throw exceptions for unvalid user inputs, some don’t. Some throw exceptions only for runtime errors, some don’t…

I personally like the way to throw exceptions even for unvalid user inputs.

Now my problem is that I have for example a user that can comment on a statement of another user (for example his/her favorit music and so on). Every user is only allowed once to comment on it. Now the function which creates a database entry for the comment, checks whether the user has already commented on that statement.
If yes, throw an exception. Normally I would say that I name this exception: ExceptionStatementAlreadyCommented
but I have many other functions in this project and if I always create such specific exceptions I would end up with about 100 – 200 exceptions.

Does this affect the performance? I autoload the classes needed via the __autoload function, so the actual exception is only loaded when it is needed.

Is it a good way to name exceptions like this?
In the past I had trouble with using one exception for different errors because when I catched the exceptions, I sometimes catch exception that I did not want to catch.

Thank you really much for your help!

Best regards,

Freddy

  • 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-06-07T16:40:30+00:00Added an answer on June 7, 2026 at 4:40 pm

    It’s good to have a tree of exceptions, extending from the most general to the most specific, for instance, your StatementAlreadyCommentedException (That’s how it should be named, with the Exception part at the end) should inherit from InvalidUserInputException, or maybe AlreadyExistsException exception, and those should inherit from something more general, like Exception.

    This way, you can catch all exceptions more specific than the one you’re searching (should you ever need it). (You can catch Exception, and it would catch every possible exception, you can catch AlreadyExistsException and it would catch any exception extending it.

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

Sidebar

Related Questions

I have a pretty large project in front of me that I intend to
I am working on a pretty large PHP class that does a lot of
I am working on a large scale project where a custom (pretty good and
I'm working on a large-size dual AS3/Flex project (some parts are pure AS3, other
I have a very large project that uses Oracle ODP.NET. Right now it is
At work we have a pretty large web application that works by having a
I'm in the process of working on programming project that involves some pretty extensive
I have a pretty large social network type site I have working on for
I'm working on a flash project that incorporates a lot of artwork done in
So I'm working on this project, and its rather large in size. I've have

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.