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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:09:46+00:00 2026-05-11T19:09:46+00:00

Do you prefer checked exception handling like in Java or unchecked exception handling like

  • 0

Do you prefer checked exception handling like in Java or unchecked exception handling like in C# and why?

  • 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-11T19:09:46+00:00Added an answer on May 11, 2026 at 7:09 pm

    Meh.

    Checked exceptions are a great thing when used properly, but more often than not they lead to stuff like:

    doSomething();
    try
    {
      somethingThrowsCheckedException();
    }
    catch(ThatCheckedException)
    { }
    doSomethingElse();    
    

    And, frankly, that’s just wrong. You should let exceptions you don’t handle bubble up.

    Checked exceptions used properly can be good. But very frequently, the result of doing checked exceptions properly is method signatures like this:

    public void itMightThrow() throws Exception1, Exception2, Exception3, Exception4, // ...
    Exception12, Exception13, /* ... */ Exception4499379874
    {
      // body
    }
    

    Am I exaggerating? Only slightly.

    Edit:

    That said, one thing I prefer about C# over Java when it comes to exception handling has nothing to do with checked exceptions (I can get that if I go with Spec# anyway). No, what I like is that the stack trace in C# is populated when you throw an exception, rather than when you instantiate one as it is in Java.

    Edit 2: This is for the commenters @Yishai, @Eddie, @Bill K:

    First, you should check out this thread for information on how to get a stack trace without instantiating an exception. Keep in mind that walking the stack is a heavy process and should not be done on a regular basis.

    Second, the reason I like C#’s exception stack trace being populated at throwal rather than at instantiation is that you can do things like this:

    private MyException NewException(string message)
    {
       MyException e = new MyException(message);
       Logger.LogException(message, e);
       return e;
    }
    
    // and elsewhere...
    if(mustThrow)
    {
       throw NewException("WHOOOOPSIEE!");
    }
    

    That’s a trick you can’t do in Java without having the NewException method included in the stack trace.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think you missed the right way to do exception… May 12, 2026 at 1:20 pm
  • Editorial Team
    Editorial Team added an answer Yes. The second form is the prefered approach. There is… May 12, 2026 at 1:20 pm
  • Editorial Team
    Editorial Team added an answer It's phpDoc which is used by some frameworks with reflection… May 12, 2026 at 1:20 pm

Related Questions

Java has compiler checked exceptions . When I made transition to C++, I learned
I've seen binary trees and binary searching mentioned in several books I've read lately,
I have a fairly infrequent problem occuring with source control. In the example here
I have always thought that the terms internationalization and localization (and their funny abbreviations

Trending Tags

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

Top Members

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.