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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:17:47+00:00 2026-05-26T00:17:47+00:00

If I propagate a exception, do I have to eventually catch it later on?

  • 0

If I propagate a exception, do I have to eventually catch it later on?

Suppose I have this code:

public class InvalidDataException extends Exception  {
    public InvalidDataException (String e){
        super(e);
    }    
}

public class Vehicle {

    private double speed;
    private int vin;

    public Vehicle (double nspeed, int nvin) throws InvalidDataException{
        setVin(nvin);
        setSpeed(nspeed);
    } 
    public double getSpeed() {
        return speed;
    }
    public void setSpeed(double speed) throws InvalidDataException{
        if (speed < 1){
            throw new InvalidDataException("negative speed: " + speed);
        }
        this.speed = speed;
    }
    public int getVin(){
        return vin;
    }
    public void setVin(int speed){
        this.vin = speed;
    }  
}

is this ok or do i have to catch it instead?

  • 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-26T00:17:48+00:00Added an answer on May 26, 2026 at 12:17 am

    You don’t need to catch it yourself, but you probably want to. If you don’t handle it yourself, it’ll continue propagating up to the JVM, at which point it will crash and print the stack trace to standard error.

    If the exception is something that your application can handle and recover from, then you’ll obviously need to put a catch statement somewhere that will handle this specific situation.

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

Sidebar

Related Questions

I have this simple exception hierarchy: type FirstLevelException(msg) = inherit System.Exception (msg) type SecondLevelException(msg,
I have a class called RemoteError with a self.fatal method on it. This methods
I have some threads fishing into a queue for jobs, something like this: class
Java lets you create an entirely new subtype of Throwable , e.g: public class
Is it OK to have the following code in my constructor to load an
I have changed title slightly because I thought this is more appropriate question. Would
I have successfully gotten my low-level mouse hook code to work, but there are
I have an ORM class called Person, which wraps around a person table: After
I have a class whose methods require that a certain class field exists correctly.
I have a grasp on this application block with ASP.NET, but I feel unsure

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.