150 questions
3 votes
1 answer
40 views
Nodriver does not take exception if element not found?
I am trying to search for elements on a webpage and have used various methods, including text and XPath. It seems that the timeout option does not work the way I expected, and no exception is raised ...
1 vote
1 answer
109 views
What does AWS mean when they say that there are scalability issues with Checked Exceptions? [closed]
I am upgrading AWS' Java SDK from 1.x to 2.x. In 2.x, it seems that most exceptional cases are modeled with Unchecked Exceptions, as opposed to Checked Exceptions like it was in 1.x. When trying to ...
9 votes
2 answers
587 views
Are there any differences between Checked and Unchecked Exceptions at Runtime?
Checked Exceptions are powerful because they allow you to force the use-site to deal with an exceptional case. If the use-site does not handle an exceptional case (or publically announce that they are ...
4 votes
1 answer
95 views
Compilation error when calling generic method which throws generic exception
I am compiling this class: public class Test { // No throws clause here public static void main(String[] args) { doThrow(new SQLException()); } static void doThrow(Exception ...
1 vote
0 answers
163 views
exception for callable in phpstan
how can I describe the exceptions thrown from callable in phpDoc? For example I have: /** * @param callable(int): bool */ function (callable $foo, int $number): ?bool { try { return $foo(...
-1 votes
1 answer
222 views
Final rethrow in Java: Exception Handling
I was going through some Exception Handling concepts in Java and came across the concept of final rethrow. I read the following article- https://baptiste-wicht.com/posts/2010/05/better-exception-...
0 votes
0 answers
23 views
Method reference of method throwing checked exception triggers compilation error at point method reference is named [duplicate]
I have a bunch of methods, with similar signatures, compatible with Function, they each declare throws InterruptedException, and I put them in a list and select one by its index and call its apply(). ...
1 vote
0 answers
44 views
Why doesn't Java treat explicit division by zero as a compile-time exception? [duplicate]
Why is explicit division By zero not considered as compile time exception in JAVA ? Example : int x =9; int y = (int)x/0; Shouldnt compiler notify me about it ? I tried running the same and finding ...
2 votes
0 answers
49 views
Why can a caught Throwable be rethrown without declaring Throwable in the method's throws clause? [duplicate]
JLS 11.2.3 says that it is a compile time error if a method body can throw a checked exception and it does not declare the class (or a parent class) in its throws clause. In the following code, ...
0 votes
2 answers
155 views
Is there a way to detect the overflow-checking context in code?
I'm working on an importer for LitJson, to import float values from ints, and doubles, and if overflow-checking is enabled, I want to wrap a potential overflow exception in a JsonException with a bit ...
0 votes
3 answers
80 views
Is it possible to pass on an exeption thrown during a stream operation?
Consider the following java code: public void write(FrameConsumer fc) throws FFmpegFrameRecorder.Exception{ frameStream.forEach(n -> fc.consume(n)); } In this case "...
0 votes
0 answers
34 views
Why Exceptions are categorized as Checked and unchecked? [duplicate]
I got one doubt regarding exception handling. We have checked and unchecked exceptions. Why they have given like that? irrespective checked or unchecked we have to handle the exception. Then i am ...
6 votes
1 answer
5k views
What does "error: unreported exception <XXX>; must be caught or declared to be thrown" mean and how do I fix it?
New Java programmers frequently encounter errors phrased like this: "error: unreported exception <XXX>; must be caught or declared to be thrown" where XXX is the name of some ...
2 votes
1 answer
85 views
Avoiding a checked exception in a constructor
Problem I have a class with two constructors. One of them (A) throws a checked exception, and the other one (B) calls the first one. // Constructor A public ArrayValue(DataType rules, Value... content)...
1 vote
1 answer
348 views
Can I avoid illgealAccessException when checking if Class private fields are null or empty?
This is the block of code inside the boolean method that I want to check if there are any empty or null fields. It returns true if none of them are. If they are, it throws a custom exception for each ...