Questions tagged [catch-exception]

Java library that catches exceptions in a single line of code and makes them available for further analysis.

catch-exception is a simple java library that catches exceptions in a single line of code. It makes them available for further analysis.

Project page is available here.

10 questions
22
votes
2 answers

Catch error using catchError in a future and throw another type

I am not sure if this type of error handling and abstraction is done in a wrong way. Future _refresh() { return Future(() => throw someError) .catchError((error) { // maybe do something here throw abstractedError;…
Durdu
  • 4,649
  • 2
  • 27
  • 47
2
votes
1 answer

Is there a way to catch org.graalvm.polyglot.PolyglotException in karate, while a (Java) feature step is failing?

While I'm running karate feature files with java classes, the feature file step is failing with org.graalvm.polyglot.PolyglotException and do we have a way to handle those exceptions? Since there are couple of test cases which has java…
Divya
  • 65
  • 4
2
votes
2 answers

How to show success message and catch error during flutter firestore data update

I have this function Future updateMember(Member member) async { final User? user = Auth().currentUser; final docMember = FirebaseFirestore.instance.collection('users').doc(user?.uid); member.id = docMember.id; final json =…
2
votes
1 answer

Angular 6 HttpInterceptor prevent output of errors

I would like to have a HTTPInterceptor to handle all Errors. My code looks like this: return next.handle(req) .pipe( catchError((response: any) => { if (response instanceof HttpErrorResponse) { if (response.status === 401) { …
1
vote
0 answers

catchException not working with @Transactional

i'm trying to use catch-exception library with JUnit4. If i have a Service A: @Service public class A { private Z delegate; @Autowired A(Z delegate){ this.delegate = delegate; } @Transactional public Integer testValue(String v) { return…
3lio11
  • 11
  • 2
1
vote
3 answers

JAVA. I am getting an 'unreported exception' compiler error

I am trying to compile this code, but it keeps having an error, errThrower.java:37: error: unreported exception Exception; must be caught or declared to be thrown throw new Exception(); This exception is thrown in the callmethodErr(), and I…
Talia
  • 21
  • 3
1
vote
1 answer

How to expect exception in constructor with catch-exception?

Is it possible to expect exception in constructor with catch-exception? Can't figure out the syntax. For methods I am writing catchException(instance).method(); and then, for example assert caughtException() instanceof…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
0
votes
1 answer

Mockito-core 2.7.19 and CGLIB

I am running a test that uses google's catch-exception. I am using mockito-core version 2.7.19, catch-exception version 1.2.0 and junit 4.12. When I use the following statement in a test: @RunWith(org.mockito.junit.MockitoJunnitRunner.class)…
Marcelo Ribeiro
  • 113
  • 1
  • 11
-1
votes
3 answers

Android Programming catch exception message

I am writing a calculator program in Java using Android Studio. I have a try/catch block in my program, with the catch block catching a NumberFormatException for invalid input. } catch (NumberFormatException e) { } Without this try/catch block and…
-2
votes
1 answer

This method throws two different exceptions. How could man catch the two exceptions and prints exception catched for both exception types to console?

public class CatchingExceptions { private int erroneousMethod(int p) { if (p == 0) { throw new IllegalArgumentException(); } int x = 0x01; return p / (x >> Math.abs(p)); // this line will throw! …
Ting Du
  • 1
  • 1