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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:33:44+00:00 2026-05-13T16:33:44+00:00

I’m well aware of the whole argument over whether or not checked exceptions are

  • 0

I’m well aware of the whole argument over whether or not checked exceptions are a good idea and I fall on the side that they are…but that is not the point of this question. I’m in the process of designing a fairly simple compiled OOP language and I’ve decided to use checked exceptions basically as a way of returning errors without going down the C route of returning error codes.

I’m looking for some insight as to how I could improve on the Java model of checked exceptions to eliminate most of their bad aspects, perhaps a syntactic change or changing the actual functionality slightly. One of the main criticisms against checked exceptions is that lazy programmers are likely to swallow them and so errors would not appear.

Perhaps it could be optional to catch exceptions and therefore if one is not caught the program would crash? Or maybe there could be specific notation to denote that an exception is not being handled (like the C++ virtual function ‘= 0’ notation)? Or I could even cause the program to crash if the exception handler is empty (though this might surprise programmers new to the language)?

How about the try…catch syntax, do you think there could be a more concise way of expressing that an exception is being caught? The language will use a garbage collector, much like Java, so is there any need for the finally clause? Finally, what other disadvantages are there to checked exceptions and what potential solutions (if any) exist?

  • 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-13T16:33:44+00:00Added an answer on May 13, 2026 at 4:33 pm

    I’m well aware of the whole argument over whether or not checked exceptions are a good idea and I fall on the side that they are…

    FWIW, I agree — by and large, they’re a Good Thing(tm). The bad habits of programmers around the use of a feature do not necessarily mean a feature is bad. In most cases, I think programmers don’t understand that they can take a pass on the exception and buck it up the chain.

    Perhaps it could be optional to catch exceptions and therefore if one is not caught the program would crash?

    Java has that feature (RuntimeException and its subclasses are unchecked exceptions).

    Or maybe there could be specific notation to denote that an exception is not being handled…

    Java has that; the throws clause in the method declaration.

    How about the try…catch syntax, do you think there could be a more concise way of expressing that an exception is being caught?

    Granted it can feel a bit clunky, but the goal is to factor exceptional conditions out of the mainline logic.

    However, I do have a couple of suggestions for try..catch:

    catch..from

    This is something I’ve wanted in Java and related languages for a long time (really need to write this up properly and submit a JSR): catch...from.

    Here’s an example:

    FileOutputStream    output;
    Socket              socket;
    InputStream         input;
    byte[]              buffer;
    int                 count;
    
    // Not shown: Opening the input and output, allocating the buffer,
    // getting the socket's input stream
    
    try
    {
        while (/* ... */)
        {
            count = input.read(buffer, 0, buffer.length);
            output.write(buffer, 0, count);
    
            // ...
        }
    }
    catch (IOException ioe from input)
    {
        // Handle the error reading the socket
    }
    catch (IOException ioe from output)
    {
        // Handle the error writing to the file
    }
    

    As you can see, the goal here is to separate the unrelated error handling for socket read errors and file write errors. Very basic idea, but there are a lot of subtleties involved. For instance, exceptions thrown by other objects being used under-the-covers by the socket or file output stream instance need to be handled as though thrown by that instance (not that hard, just need to be sure instance information is in the stack trace).

    This is something one can do with existing mechanisms and strict coding guidelines, but it’s very difficult.

    Multiple catch expressions in a single block

    A’la the planned JDK7 enhancements.

    Retry

    Very, very much harder to provide than the above and also much easier for people to work around, so the value’s a lot lower. But: Provide a “retry” semantic:

    try
    {
        // ...stuff here...
    
        if (condition)
        {
            foo.doSomething();
        }
    
        // ...stuff here...
    }
    catch (SomeException se)
    {
        if (foo.takeRemedialAction() == Remedy.SUCCESS)
        {
            retry;
        }
    
        // ...handle exception normally...
    }
    

    Here, doSomething can fail in an exceptional way, but in a way that takeRemedialAction may be able to correct. This continues the theme of keeping the exceptional conditions out of the main line of logic. Naturally, retry takes execution back to the operation that failed, which may be deep in doSomething or some submethod it’s called. You see what I mean about challenging.

    This one is much easier for teams to do with existing mechanisms: Just make subroutine that’s doSomething plus takeRemedialAction on exception, and put that call in the main line logic instead. So, this one’s low on the list, but hey…

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

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.