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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:37:40+00:00 2026-06-13T00:37:40+00:00

I get an unhandled Exception type error for the following code, even though, as

  • 0

I get an unhandled Exception type error for the following code, even though, as I understand it, I have handled the exception in the catch block.

class NewException extends Exception{
private String msg;
public NewException(String msg){
    this.msg = msg;
}
public String getExceptionMsg(){
    return msg;
}}
class CatchException {
public static void method () throws NewException{
    try {
        throw new NewException("New exception thrown");
    }
    catch (NewException e){
        e.printStackTrace();
        System.out.println(e.getExceptionMsg());
    }
    finally {
        System.out.println("In finally");
    }
}}
public class TestExceptions{
public static void main(String[] args){
    CatchException.method();
}}
  • 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-13T00:37:41+00:00Added an answer on June 13, 2026 at 12:37 am

    Your method() declares that it throws NewException. Whatever is inside that method is irrelevant:

    public static void method () throws NewException{
        //...
    }}
    
    public static void main(String[] args){
        CatchException.method();
    }}
    

    The compiler sees that you are calling CatchException.method() in main() and that you are not handling it in any way (either catching or declaring main() to throw NewException as well. Thus the error.

    The compiler doesn’t care if you are actually throwing that exception or not. Have a look at ByteArrayInputStream.close() – there is no way it’ll ever throw an IOException – but you still have to handle it since it’s declared.

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

Sidebar

Related Questions

I get the following error: Unhandled Exception: System.IO.IOException: The parameter is incorrect. at System.IO.__Error.WinIOError(Int32
Error: Unhandled exception type IOException. File imgLoc = new File(player.png); BufferedImage img = ImageIO.read(imgLoc);
Error im getting: An unhandled exception of type 'System.StackOverflowException' occurred in System.Management.dll My callstack:
I have the following simple code: import java.io.*; class IO { public static void
What might be going on here? I get Unhandled exception at 0x5081f508 (msvcr100d.dll) in
I want to get Default Windows Forms Unhandled-Exception Dialog whenever my C# application encounters
currently I used SetUnhandledExceptionFilter() to provide callback to get information when an unhandled exception
Does a destructor get called if the app crashes? If it's an unhandled exception
I am developing a c# application and I get the following error at debug
Possible Duplicate: C++ Windows Forms application unhandled exception error when textbox empty I'm building

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.