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

  • Home
  • SEARCH
  • 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 937479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:29:12+00:00 2026-05-15T21:29:12+00:00

If a method fails to do what it says it will do (e.g. if

  • 0
  1. If a method fails to do what it says it will do (e.g. if SendEmail fails to send an email), it should throw an exception. I blogged about this in-depth (optional read): Do your work, or throw an exception – example. It seems this idea is already a convention, even though I have not found it described elsewhere. “Exceptions are for exceptional cases” is a different guideline requiring an additional guideline “Do not use exceptions for normal flow control”, and requiring discussion on what is “exceptional”. “Do your work or throw an exception” is as unambiguous as the responsibility of the method (which already should be unambiguous).
  2. All methods, including “Try” methods (e.g. TrySendEmail), should always throw if some unrecoverable error happens–something that adversely affects other features of the app, not just the functionality being attempted, such as RamChipExplodedException. That is, even though “TrySendEmail” technically accomplishes what the name indicates (it tries to send an email), it should still throw an exception if the RAM explodes (if it can even do that… you get my drift).
  3. “Try” methods should be used only in special cases.

Are these always good guidelines (i.e., are there any exceptions (pun!) to the rule)? Can you think of any others not covered by these?

To clarify, I’m not asking for more specific rules of thumb to help follow these guidelines; I’m looking for additional guidelines.

  • 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-15T21:29:12+00:00Added an answer on May 15, 2026 at 9:29 pm

    For me, the #1 rule is: avoid exceptions in normal flow. When you debug, make sure all thrown exceptions are signalled. It is the first indication that your code is working the way you designed it.

    TryXXX should not throw exceptions unless you violate the design contract. So for instance TrySendMail() may throw if you pass in a null pointer as the text for the email.
    You need TryXXX methods if there is no way to get “normal flow” exception free without them. So for parsing data, they’re essential, I would not reccomend a TryLogin function.

    “Do your work or throw” is a good starting point, but I would not make it a dogma. I am OK with a collection returning -1 if you ask IndexOf an item that isn’t there. You can discuss with your colleages where you want to draw the line and put in your coding standards.

    I also use exceptions a lot to label control paths that I think are not used. For instance if I am forced to write a GetHashCode function that I assume won’t be called, I make it throw.

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

Sidebar

Ask A Question

Stats

  • Questions 497k
  • Answers 497k
  • 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 The possible (in my humble opinion) of why Twitter removed… May 16, 2026 at 12:07 pm
  • Editorial Team
    Editorial Team added an answer The basic knowledge you will find here Importing and Exporting… May 16, 2026 at 12:07 pm
  • Editorial Team
    Editorial Team added an answer EDIT: I re-read your question... again. I think I had… May 16, 2026 at 12:07 pm

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

So for this model method: def tax_rate tax_rate = 0.0 tax_rate += STATE_TAX if
I know two approaches to Exception handling, lets have a look at them. Contract
I have a method that looks similar to the following: public void myMethod(MyClass c)
obj.update_attribute(:only_one_field, 'Some Value') obj.update_attributes(field1: 'value', field2: 'value2', field3: 'value3') Both of these will update
I have a method where I need to resolve the Type of a class.
The SKProductsRequestDelegate has one single method: - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response Usually, I find
Ok, I didn't want a bunch of ICommands in my MVVM ViewModels so I
How do you look up a user in Active Directory? Some example usernames are:
Let me give a scenario then see if anyone has a solution / work-around.
In production, I maintain two sites - beta and release. Each points to a

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.