New topic: Problem with Sub Class of the Exception Class
<http://forums.realsoftware.com/viewtopic.php?t=26927> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message skids Post subject: Problem with Sub Class of the Exception ClassPosted: Sat Mar 14, 2009 4:56 pm Joined: Wed Mar 14, 2007 11:35 am Posts: 19 Hi, I followed an example listed in Matt Neuburg's RealBasic book and attempted to us a create my own exception subclass. I have created a class named myException and given it a text property and a super of RunTimeException. The following code is in a buttons action event and from page 248 of the book: dim err as MyException dim d as date d=new date if d.year =2009 then err= new MyException err.text = "Sorry, you can't use this code in 2009" raise err end exception err as MyException //this line fails on the variable err MsgBox err.text quit When I attempt to run in the RB editor the line "exception err as MyException" is displayed with the err highlighted and an error of "This name is already in use". I have tried changing the name err but I get the same error. Any thoughts? I am using RB2008 r3.1 on an Intel based MacBook running leopard. best wishes Simon Top npalardy Post subject: Re: Problem with Sub Class of the Exception ClassPosted: Sat Mar 14, 2009 5:24 pm Joined: Sat Dec 24, 2005 8:18 pm Posts: 4595 Location: Canada, Alberta, Near Red Deer skids wrote:Hi, I followed an example listed in Matt Neuburg's RealBasic book and attempted to us a create my own exception subclass. I have created a class named myException and given it a text property and a super of RunTimeException. The following code is in a buttons action event and from page 248 of the book: dim err as MyException dim d as date d=new date if d.year =2009 then err= new MyException err.text = "Sorry, you can't use this code in 2009" raise err end exception err as MyException //this line fails on the variable err MsgBox err.text quit When I attempt to run in the RB editor the line "exception err as MyException" is displayed with the err highlighted and an error of "This name is already in use". I have tried changing the name err but I get the same error. Any thoughts? I am using RB2008 r3.1 on an Intel based MacBook running leopard. best wishes Simon err is already used that's the problem try dim err as MyException dim d as date d=new date if d.year =2009 then err= new MyException err.text = "Sorry, you can't use this code in 2009" raise err end exception exc as MyException MsgBox exc.text quit _________________ My web site Great White Software RBLibrary.com REALbasic learning Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 900 classes with 18000 functions in one REALbasic plug-in. The Monkeybread Software Realbasic Plugin v8.1. <http://www.monkeybreadsoftware.de/realbasic/plugins.shtml> [email protected]
