Questions tagged [throwable]

The `Throwable` class is the superclass of all errors and exceptions in the Java programming language. Only objects that are instances of this class (or one of its subclasses) are thrown by the Java VM or could be thrown by the Java `throw` statement.

The Throwable class is the superclass of all errors and exceptions in the Java programming language. Only objects that are instances of this class (or one of its subclasses) are thrown by the Java VM or could be thrown by the Java throw statement. Similarly, only this class or one of its subclasses can be the argument type in a catch clause. For the purposes of compile-time checking of exceptions, Throwable and any subclass of Throwable that is not also a subclass of either RuntimeException or Error are regarded as checked exceptions.

For the further details and reference the documentation for Class Throwable.

165 questions
2
votes
2 answers

trap exceptions comprehensively in Jython

This is my attempt so far to trap all exceptions in Jython code. The most difficult thing, I find, is trapping exceptions when you override a method from a Java class: with the "vigil" decorator below (which also tests whether the EDT/Event…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
2
votes
4 answers

Java Thread stops without Exception/Throwable

I've a very annoying problem and I'm not able to fix this by myself. I have a simple JavaFX Scene with just 2 buttons for start and killing the thread. The stop-action is not relevant in this case because I'm not able to get the thread working well.…
2
votes
4 answers

What is the correct way to compare two throwables?

I am using a JUnit Rule to immediately re-run any failed tests. My extra requirement is, if the re-run also fails, determine whether they failed for the same reason. To do this I've adapted the code from this answer to keep a record of the failures…
bobble14988
  • 1,749
  • 5
  • 26
  • 38
2
votes
3 answers

How can I fix 'No exception of type SomeException can be thrown; an exception type must be a subclass of Throwable'

I have java webstart app and want to use app API for testing purposes. So I get required (as I assumed) library from webserver and install it to maven repository. And all is fine except custom exception which received No exception of type…
user3535807
  • 248
  • 2
  • 3
  • 15
2
votes
1 answer

Which java.lang.Error descendant are safe to catch?

Its absolutely clear for me, that usually a Java program should not catch Throwable, since it is catching Error-s like OutOfMemoryError. 100% clear. But. If I have a multi-threaded application, it is usually a best practice, that I should have an…
2
votes
2 answers

Java Exception toString() inclusive causes

Is there any good function collecting all causes of an Exception in a string? The method printStackTrace() collect them with their StackTraces: HighLevelException: MidLevelException: LowLevelException at Junk.a(Junk.java:13) …
Olivier Faucheux
  • 2,520
  • 3
  • 29
  • 37
2
votes
2 answers

Catching Exception in java to make application continue its execution

This is what i have right now, this method open's a connection with http url, public static void setCameraList(String list) { URL calculator; try { String url = "http://example.com/index.php?cameraList="…
XTop
  • 255
  • 2
  • 9
2
votes
2 answers

Java: Most efficient way to convert an throwable/exception's entire stack trace into a ByteBuffer?

What is the most efficient method to convert an throwable/exception's entire stack trace into a ByteBuffer (in Java)? Specifically, I need to log the entire exception into the database. The Thread.currentThread().getStackTrace() returns a list of…
ikevin8me
  • 4,253
  • 5
  • 44
  • 84
1
vote
0 answers

In java we use try catch with exceptions in the try block. can we use this for throwables or can we create even throwables as implements serializers?

Exceptions are extensions of throwables and throwables are defined as implementing serializers in the java packages so can we create throwables in and use try catch and reduce the severity of throwable as exceptions are more threatening. will this…
Trriger
  • 48
  • 10
1
vote
0 answers

Catch and rethrow an exception for monitoring

We are monitoring our application by using timers. In case of an exception, we would like to catch the exception, stop the timer with an error, and rethrow the same exception without handling it. Which of the following catch objects would be the…
Elad Cohen
  • 79
  • 9
1
vote
0 answers

Xamarin android App crashes with error android.runtime.JavaProxyThrowable reported in Google Play Console Vitals

My app works perfectly fine both in debug and release mode. But in Google play store vitals section there are 3000+ crashes reported within a weeks time with stacktrace as shown below. I am not able to understand this log so as to locate the reason…
Ovais Khan
  • 205
  • 2
  • 16
1
vote
3 answers

Loop continuing even after hitting return statement

I have the following method where I wan to keep checking if a nested exception matches an IndexOutOfBoundsException unless the nested exception is the same as the previous one. It seems to do the right thing where in my test, the first exception is…
karvai
  • 2,417
  • 16
  • 31
1
vote
1 answer

Why does fetching results using "new Throwable().getStackTrace()[1].getMethodName()" termed as expensive?

I am using new Throwable().getStackTrace()[1].getMethodName() It is termed as expensive by some developers. In what way this method is expensive? Shall we use it and if yes then what caution should be taken? In my use case, it is very much…
fatherazrael
  • 5,511
  • 16
  • 71
  • 155
1
vote
4 answers

throwing Class

so I have a function which looks like this: public void addExceptionCommands(Class exClass, Command... commands) { for (Command command : commands) { try { //Push the command to the stack…
Jakub Balicki
  • 180
  • 1
  • 11
1
vote
2 answers

Assertions.assertThrows returns void while it must return Throwable | JUnit 5

I am using JUnit 5 library and I try to use assertThrows and get the exception thrown in order to get the message of the exception. I have such piece of code: import org.junit.jupiter.api.Assertions; //import org.junit.Assert; import…
ibodi
  • 1,543
  • 3
  • 21
  • 40