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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:57:46+00:00 2026-05-22T16:57:46+00:00

I am writing a method which makes sure that the caller is authorized to

  • 0

I am writing a method which makes sure that the caller is authorized to execute it. When the user isn’t authorized, I have to throw an exception (see code below). What should be the name of that method?

public void Compute() {
    this.CheckIfCallerAuthorizedOrThrow(); // Is it a good name? Better idea?

    // ...
}

I want to make sure that someone who reads the code understand that the flow of the method can be broken here by an exception. Is that a good or bad practice in this case to have a method name with “throw” in it?

  • 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-22T16:57:47+00:00Added an answer on May 22, 2026 at 4:57 pm

    Honestly, a method name should describe exactly what it is supposed to do. So in a way, that’s a good name. However, an exception is a way of saying “This method couldn’t complete successfully and here’s why…”. Just about every method you write could throw an exception, so it wouldn’t make sense to document exceptions in the name of every method.

    You should consider using XML documentation. XML documentation is more specific too. It tells what type of exception is being thrown, as well as the specific reasons it will be thrown.

    I do actually use method names with “throw” in them, but they are usually really short private methods that I reuse in several other public methods. They usually look like this:

    private void doSomethingOrThrow(object args)
    {
        if (args == null)
            throw new ArgumentNullException();
        doSomething();
    }
    

    So, in short, that’s potentially a good method name. I just wouldn’t use “throw” in every single method that throws exceptions. Besides, a good developer will need to look at the documentation anyway to see what kind of exceptions are being thrown (I certainly hope he’s not just catching the generic Exception all the time…)

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

Sidebar

Related Questions

I've got a method in a class that's writing to some string, which calls
I'm writing a method which approximates the Kolmogorov complexity of a String by following
I'm writing a select query in a C# method which lets client code provide
I have a doubt about orkut's new URL Writing method. Earlier the home page
I am writing an method that takes variable lengths of arrays and compresses and
I am writing a Clone method using reflection. How do I detect that a
I am writing a deserialization method that converts xml to a Java object. I
I'm currently writing a method which, in order to reduce transaction costs, inserts entities
I have an NHibernate Transaction that does some work and makes a call to
Writing a PHP app and have several classes that only have static methods (no

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.