  | |  | Exception Handling missing a key feature | Exception Handling missing a key feature 2004-03-11 - By Doklovic, Jonathan
Back Hi.
First of all, does anyone have any examples of *real* exception handling using custom exceptions I can check out???
I've been writing some code that throws custom Exceptions. (extending error class). The problem is, there's no "throws" clause for class methods. This means that I can write all the custom exceptions I want until the cows come home, but there's nothing forcing me to handle them.
I'm not sure why this is missing. When writing components and such that are going to be distributed, it would be VERY nice to have a throws clause. This way, the developer will know what exceptions he/she needs to watch out for. The compiler should throw an errror if the exception is not handled in some way. This should work just like JAVA.
Example:
Import com.mySite.util.xml.XMLException;
class com.mySite.util.SomeClass throws XMLException { private var settingsProvider:XML; public var xmlPath:String; public function SomeClass(xmlPath:String) { this.xmlPath = xmlPath;
settingsProvider = new XML(); var settingsProvider.master:SomeClass = this; settingsProvider.load(xmlPath); settingsProvider.onLoad = onLoadSettings; }
public function onLoadSettings(successfull:Boolean):Void { if(!successfull) { master.xmlError(); } else { master.init(this); } }
public function xmlError():Void { throw new XMLException("Error loading XML:\nError occured in com.mySite.util.SomeClass.\nTrying to load settingsProvider from: " + xmlPath); }
public function init(xml:XML):Void{}
Now if id do:
Var myClass:SomeClass = new SomeClass("http://server/myxml.xml");
I should get a compiler error saying that SomeClass throws an XMLException that I must handle.
Just some thoughts. Again, any examples of complex exception handling would be appreciated.
Thanks!
jonathanDoklovic seniorProgrammerAnalyst limitedBrandsTechnologyServices http://www.victoriassecret.com
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106627 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |