No, you don't "inherit" non-default constructors, you need to define the one taking a String in your class. Typically you use super(message) in your constructor to invoke your parent constructor. For example, like this:

public class MyException extends Exception {
    public MyException(String message) {
        super(message);
    }
}
Answer from djna on Stack Overflow
🌐
Coding Shuttle
codingshuttle.com › java-programming-handbook › class-exception
Class Exception in Java
April 9, 2025 - Java allows developers to create their own exception classes by extending Exception. When built-in exceptions do not represent a specific error scenario in your application.
Discussions

How do you structure your exception classes?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/java
33
44
January 17, 2024
java.lang Exception hierarchy - why?
I have been having trouble understanding the motivation regarding the inheritance hierarchy established with the top level exception classes in java.lang. More specifically, I am wondering why java.lang. RuntimeException (an unchecked exception) has been placed as a subclass to... More on thecodingforums.com
🌐 thecodingforums.com
11
January 10, 2004
Was doing great in Java class until Exceptions. This one stupid thing is gonna make me fail
What's the problem? An exception is just a problem that needs to be handled or else the program will crash. And the exception needs to be handled because exceptions are (typically) thrown in cases where some code has reached an invalid state. If some code doesn't understand how it can resolve the problem, it can throw an exception to request that some "parent" code handle it. Like, say you have a game, and one time when it goes to load the player's save, it finds that there is no save available? It might throw an exception at that point to tell some code higher up in the call chain that it can't handle a problem. It's a way of passing control to some other code that has the context to deal with the problem. Make sure you understand the stack, or understanding what trys handle errors will be impossible for anything nontrivial. More on reddit.com
🌐 r/learnprogramming
61
70
October 22, 2024
A Throwable other than Error or Exception?
Extending Throwable or Exception (but not RuntimeException) results in a checked exception. Extending Error or RuntimeException results in an unchecked exception. That's the basics. But you really should not extend Throwable. Some absurdly high percentage of code will likely only check for subclasses of Exception. There are... exceptions... obviously. If you have a centralized error handling system, then you may want to catch throwable, and then wrap it in a subclass of Error and log it specially. One thing to note is subclasses of Error. These you can, in your handler, log them or do something lightweight. But you should nearly always re-throw Error. As an example, let's say you are running in Tomcat, and you end up eating ThreadDeathError in your exception handler. Now, the container has no idea that there was an issue with a thread, which can eventually lead to resource leaks and instability. TL/DR: Do not extend Throwable directly, always re-throw Error when encountered. And just my own PoV, avoid checked exceptions when you can. These just add overhead to callers. Most successors to Java have jettisoned checked exceptions, which are not any different in the JVM at runtime in any event from unchecked ones. More on reddit.com
🌐 r/java
55
18
July 2, 2024
🌐
Quora
quora.com › What-is-the-process-for-finding-all-the-exceptions-thrown-by-an-exception-class-in-Java
What is the process for finding all the exceptions thrown by an exception class in Java? - Quora
Answer: As a happy and relatively adept user of JetBrains / IntelliJ IDEA, this is what I’d do: Ask IDEA to show me all instantiations of the specific [code ]Exception[/code] class. Most exceptions are not instantiated through some intermediary code such as a factory, so usually this is the ...
🌐
Tutorialspoint
tutorialspoint.com › java › java_exceptions.htm
Java - Exceptions
Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation. All exception classes are subtypes of the java.lang.Exception class.
🌐
Rollbar
rollbar.com › home › java exceptions hierarchy explained
Java Exceptions Hierarchy Explained | Rollbar
May 15, 2025 - Java exceptions can be of several types and all exception types are organized in a fundamental hierarchy. Understanding this hierarchy is crucial for implementing robust error handling strategies in production. The class at the top of the exception class hierarchy is the Throwable class, which is a direct subclass of the Object class.
🌐
Stackify
stackify.com › types-of-exceptions-java
Types of Exceptions in Java - Stackify
March 14, 2024 - Now let us explore different types of exceptions in Java. The parent class of all the exception classes is the java.lang.Exception class.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Exception.html
Exception (Java Platform SE 8 )
October 20, 2025 - The class Exception and any subclasses that are not also subclasses of RuntimeException are checked exceptions. Checked exceptions need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method ...
Find elsewhere
🌐
DigitalOcean
digitalocean.com › community › tutorials › exception-handling-in-java
Exception Handling in Java | DigitalOcean
October 6, 2022 - RuntimeException is the parent class of all Runtime Exceptions. If we are throwing any Runtime Exception in a method, it’s not required to specify them in the method signature throws clause. Runtime exceptions can be avoided with better programming. Java Exception and all of its subclasses ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.exception
Exception Class (Java.Lang) | Microsoft Learn
The class Exception and any subclasses that are not also subclasses of RuntimeException are <em>checked exceptions</em>. Checked exceptions need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary. Added in 1.0. Java documentation for java.lang.Exception.
🌐
Raygun
raygun.com › blog › java-exceptions-terminology
Java exceptions: Common terminology with examples · Raygun Blog
October 25, 2022 - Exception throwing in Java happens with the throw statement. ArithmeticException, ArrayIndexOutOfBoundsException, NullPointerException, and IOException in our examples were all thrown automatically by the Java platform.
🌐
Reddit
reddit.com › r/java › how do you structure your exception classes?
r/java on Reddit: How do you structure your exception classes?
January 17, 2024 -

On my team, we mostly use the built-in Java exceptions with a top level try-catch that logs and alerts us.

You probably see where this is going.. we get alerted for every single exception, and many of these are not actionable by us (user errors).

We now have a filter layer that filters out alerts that match a regex, so we aren’t alerted for everything now but it’s still not ideal.

I want a way to distinguish between exceptions we need to be alerted on and exceptions that can just be warnings.

I see 2 main approaches:

  1. An AlertException class that we subclass and throw. We catch these at the top level and alert accordingly.

  2. Some sort of Alertable marker interface that we throw and do an instance of check on. One variant is the interface could also have a method like “responseType” that returns an enum with values like: Alert Oncall, Warn, Alert user

I’m leaning towards approach 2 but would love to hear your ideas! Thanks!

Top answer
1 of 22
55
Is this a Spring Web app? If so there is a built-in annotation called @ControllerAdvice. You can annotate a global exception handler class with that and you can handle custom exceptions using that. For the custom exceptions you'll want to subclass the built-in Exception class.
2 of 22
24
I would at the very least define your own exception base type so that every exception that your code throws is an instance of that type. Depending on how many systems/modules/libraries your systems consists of, perhaps you need more than one base type. If you're interested in differences in meaning between various instances of your base type exception then I recommend creating different subclasses, but I would try to make those meaningful in the sense that they should convey what sort of error they're signalling. We now have a filter layer that filters out alerts that match a regex This you should not be doing. The information you need to make these decisions should be communicated either via structured fields (enums, booleans, etc) or the exception type. An AlertException class that we subclass and throw This I would definitely not do. The whole point of exceptions is that in your code when something bad happens you can package up information about the problem and throw it up the stack so that higher-level code which knows what the context is can handle the problem. Because what the correct error handling is depends on context. If you have a class like this then basically every time you throw an exception you have to make this alert/not alert decision, but you don't want those decisions spread all over the codebase. You also don't necessarily know everywhere in the codebase whether this is alertable or not. Instead, make the code communicate what sort of error has happened, and then have the decisions at higher levels. Personally, I think it sounds odd to do alerting on individual exceptions instead of using metrics and defining alerts on those. Note that this is all generic advice, because you said nothing about what sort of application this is.
🌐
Educative
educative.io › answers › what-are-different-types-of-exceptions-in-java
What are different types of exceptions in Java?
They are used to handle errors and other exceptional events in programs written in the Java programming language. ... Checked exceptions: These are the exceptions that are checked by the compiler at compile time.
🌐
j-labs
j-labs.pl › home › tech blog › java exception handling: strategies and best practices
Java Exception Handling in Java Best Practices | j‑labs
October 9, 2025 - The exception hierarchy in Java is organized into a class hierarchy that inherits from the Throwable class.
🌐
Airbrake
blog.airbrake.io › blog › java-exception-handling › the-java-exception-class-hierarchy
The Java Exception Class Hierarchy
July 13, 2022 - The goal here is just to give a quick overview of these categories, as much more detailed looks into specific exceptions will come in future articles. AssertionError - Thrown when an assertion has failed. LinkageError - Thrown when a class dependency has some form of incompatibility, due to changes made after compilation. ThreadDeath - Thrown when the (now deprecated) Thread.stop() method is invoked. VirtualMachineError - Thrown when something goes wrong with the Java Virtual Machine, such as running out of resources.
🌐
The Coding Forums
thecodingforums.com › archive › archive › java
java.lang Exception hierarchy - why? | Java | Coding Forums
January 10, 2004 - Note that the language defines ... errors. The unchecked exceptions classes are the class RuntimeException and its subclasses, and the class Error and its subclasses....
🌐
Oracle
docs.oracle.com › en › java › javase › 19 › docs › api › java.base › java › lang › Exception.html
Exception (Java SE 19 & JDK 19)
December 12, 2022 - The class Exception and any subclasses that are not also subclasses of RuntimeException are checked exceptions. Checked exceptions need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method ...
🌐
Oracle
docs.oracle.com › javase › specs › jls › se9 › html › jls-11.html
Chapter 11. Exceptions
Every exception is represented by an instance of the class Throwable or one of its subclasses (§11.1). Such an object can be used to carry information from the point at which an exception occurs to the handler that catches it. Handlers are established by catch clauses of try statements (§14.20).
🌐
Baeldung
baeldung.com › home › java › core java › exception handling in java
Exception Handling in Java | Baeldung
May 11, 2024 - While simple, the above code can’t throw a checked exception and because of that, even though we are rethrowing a checked exception, we don’t have to mark the signature with a throws clause. This is handy with proxy classes and methods. More about this can be found here. When we mark methods with a throws keyword, it impacts how subclasses can override our method. In the circumstance where our method throws a checked exception:
🌐
GeeksforGeeks
geeksforgeeks.org › java › exceptions-in-java
Java Exception Handling - GeeksforGeeks
In Java, exception handling is a mechanism to handle runtime errors, allowing the normal flow of a program to continue. Exceptions are events that occur during program execution that disrupt the normal flow of instructions.
Published   3 weeks ago
🌐
JetBrains
blog.jetbrains.com › idea › 2024 › 03 › easy-hacks-how-to-throw-java-exceptions
Easy Hacks: How to Throw Java Exceptions | The IntelliJ IDEA Blog
March 12, 2024 - The Exception class is the typical ancestor for exceptions that can be recovered from using a try/catch block. For example, when an IOException is thrown because a file could not be found, your code can show a message to the user of your application ...