Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Can't catch specific exception

  Asked By: Ronnie    Date: Mar 20    Category: Java    Views: 846
  

I have a situation like this:


class myEx extends Exception {}

class MyEx1 extends MyEx {}

class A
{
public void method1() throws MyEx1
{
}
}

class B extends GenericPortlet
{
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
{
try {
A a = new A();
a.method1();
}
catch (MyEx1) {
}
catch (myEx) {
}
catch (Exception) {
}
}
}

why is it possible that when i throw an MyEx1 in A.method1 i can't catch it in my instance of B as MyEx1 or MyEx. I can only catch it as an Exception. I also try to cast it to MyEx1 but it didn't work.

I'm using JBoss and JBoss Portal

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Frank Butler     Answered On: Mar 20

Is your customized class  extend a "Throwable" ? does it extend the proper Throwable class? you might need to extend Exception which is in turn a throwable type class

 
Didn't find what you were looking for? Find more on Can't catch specific exception Or get search suggestion and latest updates.




Tagged: