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
0
votes
1 answer

Selenium - Throwable does not catch exception

I am trying to use throwable class in my code given below & for some reason its not catching an exception in particular scenario. My test case is to verify a particular text on google search page after Safe Search mode is On. So basically i am…
Amar
  • 1
  • 1
0
votes
1 answer

Printing stack trace including methods that have finished

So, I have this class and I want to print which methods were called. When I run it it prints only trace and main but not method1 and method2. How can I change it so it would print method1 and method2, the methods called from main? public class…
0
votes
4 answers

Why can't I handle Exception e with try / catch clause?

When I compile the following code everything goes fine and output is as expected: class Propogate { public static void main(String[] args) { Propogate obj = new Propogate(); try { obj.reverse(""); } catch…
paniclater
  • 903
  • 1
  • 12
  • 18
0
votes
0 answers

Java, handling potentially large numbers of exceptions in one class - handler class?

I'm working on a Java project and I've come upon an interesting design issue. It's not exactly a problem, but it is a bit ugly with the obvious solution. I have a class implementing Callable, although with the current implementation it could just as…
user1017413
  • 2,023
  • 4
  • 26
  • 41
0
votes
3 answers

what is the purpose of creating your own Exception class

Can anyone explain what the purpose is of creating your own Exception class by subclassing java.lang.Exception? Why can't you just make your own traditional class that deals with Exceptions? Can anyone provide an example about why it's useful to…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Should "Throwable" ever be thrown?

I am editing someone elses code, and a method had "Throws Throwable". I took that off so eclipse would let me add just the exception types that it needs to throw... however I have an error on a method called to the super class (which I have no…
glyphx
  • 195
  • 3
  • 10
0
votes
2 answers

How to get the method name from which the exception is thrown?

I need to get the class name and the method name from which the exception is thrown. How can I do that? Thanks in advance. My code: private void setErrorDetails(final Throwable cause) { for (final StackTraceElement ste : cause.getStackTrace())…
mukund
  • 317
  • 5
  • 10
  • 22
0
votes
2 answers

Throw nested exception through java Throwable

I trying to throw inner exception in another exception through java Throwable but IDE told my that you must surround it with try/cath, What should I do to avoid from this problem? try { //Some code } catch (IOException e) …
Ali
  • 2,012
  • 3
  • 25
  • 41
0
votes
2 answers

Overloading the getCause() method in a throwable object

How would one go about overloading the getCause() method in a throwable object ? I have the following but it doesn't seem to work as it says that it cannot be overloaded with a string. public class MyException extends RuntimeException { String…
Crossman
  • 278
  • 5
  • 18
-1
votes
1 answer

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…
ayush
  • 464
  • 5
  • 17
-1
votes
1 answer

How catch exceptions and store in a ArrayList

I am trying to catch exceptions generated while executing some methods in a list. I have created a different POJO class extending throwable class. public class ErrorDetails extends Throwable implements Serializable { /** * */ …
-1
votes
3 answers

does the compiler consider actual types in error handling in java

why does this work class blah{ public void someMethod(){ try{ throw new NullPointerException(); } catch(Throwable t){ System.out.println("Caught!"); throw t; } } } it…
-1
votes
1 answer

How to resolve ClassNotFoundException for Throwable in Weblogic 12c

I have a J2EE EJB 2.0 application, which was running on Glassfish perfectly. I have just finished the transformation of this application from Glassfish to Weblogic 12c (Sun Glassfish specification XMLs to Weblogic specification XMLs). When I am…
victorio
  • 6,224
  • 24
  • 77
  • 113
-3
votes
1 answer

How to pass throwable object with "401 unauthorised exception"?

I have a callback method in my java class which is expecting a Throwable object to be passed. The Exception should be 401 unauthorised exception. How can I achieve this ? if ((currentTime - refreshTime) < (expiresInFromPrefs - 5)) { …
sagar suri
  • 4,351
  • 12
  • 59
  • 122
-3
votes
3 answers

Using the Throwable class

I know that each java class should extend the Throwable class so that exceptions can be handled. Is this done by: public class Test extends Throwable or public class Test throws Throwable?
user3126119
  • 323
  • 1
  • 3
  • 10
1 2 3
10
11