Linked Questions
22 questions linked to/from How to define custom exception class in Java, the easiest way?
1
vote
1
answer
3k
views
How to modify a getMessage for an exception? [duplicate]
I need to change the return message of the method getMessage() ,
for instance, i have an ArithmeticException, and when I write:
try{c=a/0;}
catch(ArithmeticException excep){System.out.println( excep....
0
votes
0
answers
56
views
Java Throwing exception with parameters (Exception e, String... errs) [duplicate]
I am trying to write a custom exception class for a program that connects to a local MySQL database and throws an exception if we are unable to connect (bad database, username, or password).
However ...
191
votes
7
answers
114k
views
Is it unnecessary to put super() in constructor?
Isn't this one automatically put by the compiler if I don't put it in a subclass's constructor?
That means I don't even need to care about it? In some articles they put it out.
And if I've got one ...
6
votes
2
answers
5k
views
Which exception to throw when I find my data in inconsistent state in Scala?
I have a small Scala program which reads data from a data source. This data source is currently a .csv file, so it can contain data inconsistencies.
When implementing a repository pattern for my ...
3
votes
3
answers
17k
views
INvalid input exception
I have a menu which reads integers for input ,here is the method for the menu:
public int menu(String _menuHeader,String[] _menuItems) throws InvalidInputException {
int choice = 0;
do {
...
1
vote
3
answers
12k
views
Handling Exceptions Using Superclasses in Java [closed]
For homework, I have to develop an exceptions code:
"Use inheritance to create a superclass of exception called ExceptionA, and two subclasses of the exception called ExceptionB and ExceptionC, where ...
1
vote
4
answers
3k
views
Correct Java Exception for a malfomed string
I have a method that should only accept strings of a certain format. When the format is invalid, I want to throw an Exception. I'm quite new to Java, so am not sure what the correct type of exception ...
2
votes
4
answers
2k
views
Java Throwing Custom Errors
So I've been working with Java for a little while now. I technically am still new to the language.
I have created a couple custom errors for a personal project I'm working on and I was wondering if ...
9
votes
4
answers
206
views
Classes used to manage exception
Is it good to have a class with short methods used to catch Exceptions?
class ContractUtils{
public static String getCode(Contract contract) throws MyException{
try{
return contract....
2
votes
5
answers
874
views
Exceptions in method declaration in java
I have the following method to implement for an ArrayList, but I'm not sure how to go about treating the exception. If the ArrayList is empty does it automatically throw that exception or do I need to ...
0
votes
2
answers
2k
views
How to use ValueError in catch java
I want to try and catch in java,
when I wrote the catch part it asked me for a parameter,
the parameter I want to use is ValueError (as meaning in python)
Example:
try {
System.out.print("...
0
votes
2
answers
3k
views
How to write custom exceptions for login in java
I am building a web application i ve a login jsp form which will be redirected to a servlet...
My servlet code:
Login login=new Login();
login.setUserName(request.getParameter("txtUsername"))...
0
votes
5
answers
2k
views
New exception class the extends exception class and has two constructors
Create a new exception class IllegalDimensionException that extends Exception class. It will have two constructors, one default- value and one explicit value that uses the message "Illegal dimension ...
0
votes
3
answers
149
views
Exception Classes in Java
Exception Handling: Direct quote from a professor, "Although the Exception class can be used directly in a program, it is better to use a specific exception class." He did not extend much on it but ...
1
vote
2
answers
626
views
OverLimit Exception handling in java
Program to raise an exception stating "Further Transactions Not Possible until clearance of bill." when a customer's unpaid credit card amount cross $2000 or is unpaid upto 45 days. Assume that the ...