Okay, here's one for you. I extended Error with a very simple specific error type, like this:

class com.mycompany.exceptions.InvalidPathFormatException extends Error
{
   public function InvalidPathFormatException(message:String)
   {
      if (message != null)
      {
         this.message = message;
      }
      else
      {
         this.message = "General message for this error type.";
      }
   }
}


Now I try to use it with a method like this:

/**
   Does stuff.

   @throws InvalidPathFormatException
*/
public function doSomeStuff():Void
{
   if (anErrorOccurs)
   {
      throw new InvalidPathFormatException("error message");
   }
}


I call this method like this:

try
{
   doSomeStuff();
}
catch (e:InvalidPathFormatException)
{
   trace("caught the specific error");
}
catch (e:Error)
{
   trace("caught a generic error");
}


This looks completely straightforward and identical to Java... but when I do it, it catches the generic error. Now, obviously an Error instance is getting caught, which means one is getting thrown, which means my InvalidPathFormatException IS being recognized as a subclass of Error! It's just not getting caught by the right block! And it's not a priority thing, because if I omit the catch block for e:Error, I don't catch anything at all (but I DO get debug output of the string "Error").

Now, I think I'm doing this right -- I've done it in Java, and Colin Moock's book confirms that it's the same in Flash. What am I missing here? (All my exception classes are properly defined and imported or I'd be getting compile errors instead.)

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to