You could create your own Exception class:
public class InvalidSpeedException extends Exception {
public InvalidSpeedException(String message){
super(message);
}
}
In your code:
throw new InvalidSpeedException("TOO HIGH");
More Related Contents:
- NumberFormatException not wrking java
- How to create exception from another class
- Understanding checked vs unchecked exceptions in Java
- The case against checked exceptions
- Java List.add() UnsupportedOperationException
- Scanner NoSuchElementException
- Is it possible to catch out of memory exception in java? [duplicate]
- Should you report the message text of exceptions?
- Exception thrown inside catch block – will it be caught again?
- How to catch a Firebase Auth specific exceptions
- Java: Global Exception Handler
- EOFException – how to handle?
- Connection Java – MySQL : Public Key Retrieval is not allowed
- Throws or try-catch
- Difference between Unchecked exception or runtime exception
- When should Throwable be used instead of new Exception?
- method called after release() exception unable to resume with android camera
- Mockito test a void method throws an exception
- Guidelines on Exception propagation (in Java)
- Update JavaFX UI from another thread
- How can I print error stack trace in JSP page?
- Convert LocalDate in DD/MM/YYYY LocalDate [duplicate]
- java.util.ConcurrentModificationException not thrown when expected
- iText/BouncyCastle ClassNotFound org.bouncycastle.asn1.DEREncodable and org.bouncycastle.tsp.TimeStampTokenInfo
- What is the use of printStackTrace() method in Java?
- Why we don’t have to add try-catch to a RuntimeException?
- Illegal operation on empty result set [duplicate]
- Uncatchable ChuckNorrisException
- How to avoid a NoRouteToHostException?
- How to restart thread in java? [duplicate]