251 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
2
answers
129
views
Valid parenthesis problem passes tests but fails when I submit
I'm currently trying to solve the Valid Parenthesis problem on Leetcode, in Java, that goes as follows:
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if ...
1
vote
2
answers
610
views
Execute multiple concurrent (async let) tasks and throw their error only when all of them are failed
For example I need to get 2 arrays of the same type from different sources. Both of these requests may fail but I need to show any error (given by server) when these requests are failed simultaneously....
-1
votes
3
answers
165
views
Why doesn't @SneakyThrows throw a ClassCastException? [duplicate]
This question just asks why the generic cast is not used. The questions about Erasure do not seem to explain this edge case.
Before I start let me preface this by saying I am NOT interested in type ...
-1
votes
1
answer
354
views
Why is result of throwable get.Message ignored in my exception?
I made my own excpetions and I have to print the error message from the exception with a method that uses getMessage(). e.getMessage() is highlighted and it says result of Throwable.getMessage is ...
1
vote
1
answer
44
views
Setter only does assignment, yet declares that it throws a ParseException; in Hibernate
Discovered a Date setter that only does the typical assignment, yet has a throws ParseException for what seems like no good reason. No Date construction is happening in the body of the setter. Just ...
1
vote
1
answer
90
views
Try-Catch vs re throwing an exception? [closed]
I have a function fun1(), which calls fun2(), which might throw an Exception :
public <T> T fun1(final String abc) throws XYZException {
try {
fun2()
} catch (final Exception e)...
0
votes
2
answers
239
views
How to pass differents Exceptions to a Java method?
So the idea is I have a bunch of methods separated in different 'repo' classes, each one of these can arise a personalized exception (all of them created by me, extending generic Java Exception). All ...
0
votes
1
answer
639
views
Using throw new Error or try catch in Javascript async function
In below async Javascript function (which I use server side in Node js), I am doing a Graphql request using fetch api:
import GET_DATA from './getData.gql';
const getData = async (url: string) => {
...
1
vote
0
answers
27
views
Questions about exception handling in Java specifically the purpose of the throws keyword
I had a question about the throws keyword in the code below. In the method testLoop3() I am indicating that the IndexOutOfBoundsException may be thrown with the throws keyword. But the method testLoop(...
0
votes
1
answer
64
views
Generic throws clause handling in case of overridden methods
Consider the following clause from JLS: 8.4.8.3.
If the unerased throws clause of m1 does not contain a supertype of each exception type in the throws clause of m2 (adapted, if necessary, to the type ...
0
votes
0
answers
36
views
Is there a way to do variadic higher-kinded exception throws in Java?
basically the question is in the title.
I'm looking for ways to set an interface method to throw 1..N java.lang.Exception subtypes. So far I'm only able to make it work using generic type parameters ...
2
votes
1
answer
2k
views
How to inform in Kotlin that a function passed by parameter can throw an exception?
I need to inform in my class code that the function passed by parameter (convertorCall) can throw an exception.
suspend operator fun <T> invoke(
convertorCall: () -> T
): T?
For example, ...
0
votes
0
answers
1k
views
Java Optional method orElseThrow doesn't throw anything despite having a null value inside
I have some consistency issue with the Optionals in Java.
According to the documentation:
public T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X extends Throwable
If a value ...
7
votes
2
answers
429
views
Official recommendation / coding style guide on using multiple @throws tags for the same exception in JavaDoc
I just recently found out that one can use multiple @throws tags for the same exception in Javadoc.
One of my students used it to document one of his methods in Connect Four:
/*
* ...
* @throws ...
0
votes
2
answers
104
views
Throw Exception in method who throws this Excpetion
I am doing a method who return an UUID of a Minecraft player from his username using the Mojang API. This method takes a String in parameter (the username of the player who we want to know the UUID). ...