<div dir="ltr"><br><br><div class="gmail_quote">On Wed, Oct 15, 2008 at 5:22 PM, Alex Chi <span dir="ltr">&lt;<a href="mailto:alex_chi99@yahoo.com">alex_chi99@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Sorry for the that, I mean my problem is I put the exception in the wrong part of my program, so everytime I try to call it in the method it does not return the exception, so what i did was:<br>
<br>1. Create an new exception class, which is: FileNotFoundError<br><br>Smalltalk.Core defineClass: #FileNotFound<br>&nbsp;&nbsp;&nbsp; superclass: #{Core.Error}<br>&nbsp;&nbsp;&nbsp; indexedType: #none<br>&nbsp;&nbsp;&nbsp; private: false<br>&nbsp;&nbsp;&nbsp; instanceVariableNames: &#39;&#39;<br>
&nbsp;&nbsp;&nbsp; classInstanceVariableNames: &#39;&#39;<br>&nbsp;&nbsp;&nbsp; imports: &#39;&#39;<br>&nbsp;&nbsp;&nbsp; category: &#39;&#39;<br><br>2. I use that new exception to raise signal on a FileNotFoundError.<br>&nbsp;&nbsp;&nbsp; fileNotFound<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 ^FileNotFound raiseSignal: &#39;The file is not exist&#39;<br></div></div></div></blockquote></div><br><br>Which version of Smalltalk are you using? This doesn&#39;t look like Squeak to me.<br><br>If you want an Exception object, you could just return a new instance:<br>
<br>fileNotFound<br>&nbsp;&nbsp; ^ FileDoesNotExistException new.<br><br>Although this method is pretty pointless.<br><br>I think you&#39;re misunderstanding how Exceptions work; you need to do more reading. I&#39;m not sure if Smalltalk Exceptions are well documented anywhere, but I do know that they work in a similar way to exceptions in other programming languages such as Java or Python, so you could Google or get books from a library that describe these.<br>
<br>Briefly, Exceptions are intended for handling situations where something goes wrong. See &quot;FileDoesNotExistException class&gt;&gt;example&quot; for an example.<br><br>Gulik.<br clear="all"><br>-- <br><a href="http://people.squeakfoundation.org/person/mikevdg">http://people.squeakfoundation.org/person/mikevdg</a><br>
<a href="http://gulik.pbwiki.com/">http://gulik.pbwiki.com/</a><br>
</div>