Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

exception bug? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: SaveAsDialog BUG OS X
Next thread: Re: Canvas.Paint difference between Mac OS X and Windows XP


Win32 API Declares   -   Berg, Heath
  exception bug?   -   Will Leshner
   Re: exception bug?   -   Brady Duga
   Re: exception bug?   -   Norman Palardy
   Re: exception bug?   -   Brady Duga
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Brady Duga
   Re: exception bug?   -   Jonathan Johnson
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Brady Duga
   Re: exception bug?   -   Norman Palardy
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Will Leshner
   Re: exception bug?   -   Brad Rhine

exception bug?
Date: 19.08.05 19:06 (Fri, 19 Aug 2005 11:06:11 -0700)
From: Will Leshner
Given the following code, wouldn't we expect to see the "Caught a
NilObjectException" message?

try

raise new NilObjectException

catch KeyNotFoundException
MsgBox "Caught a KeyNotFoundException."
catch NilObjectException
MsgBox "Caught a NilObjectException."
finally
MsgBox "In try finally block."
end try

In my tests, I don't. I see the "Caught a KeyNotFoundException"
message. If I add in variables to the Catch statements, then it works:

try

raise new NilObjectException

catch e as KeyNotFoundException
MsgBox "Caught a KeyNotFoundException."
catch e as NilObjectException
MsgBox "Caught a NilObjectException."
finally
MsgBox "In try finally block."
end try

Re: exception bug?
Date: 19.08.05 19:31 (Fri, 19 Aug 2005 11:31:41 -0700)
From: Brady Duga

On Aug 19, 2005, at 11:06 AM, Will Leshner wrote:

> Given the following code, wouldn't we expect to see the "Caught a
> NilObjectException" message?

No, but it is an excellent example of bad programming style.

--Brady
The La Jolla Underground

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exception bug?
Date: 19.08.05 19:53 (Fri, 19 Aug 2005 12:53:31 -0600)
From: Norman Palardy

On Aug 19, 2005, at 12:31 PM, Brady Duga wrote:

>
> On Aug 19, 2005, at 11:06 AM, Will Leshner wrote:
>
>> Given the following code, wouldn't we expect to see the "Caught a
>> NilObjectException" message?
>
> No, but it is an excellent example of bad programming style.
>
LOL ... he should just reach over and whack you one !

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exception bug?
Date: 19.08.05 20:03 (Fri, 19 Aug 2005 12:03:58 -0700)
From: Brady Duga

On Aug 19, 2005, at 11:53 AM, Norman Palardy wrote:
>
> LOL ... he should just reach over and whack you one !

Ah, but he can't - I work at home on Fridays :)

--Brady
The La Jolla Underground

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exception bug?
Date: 19.08.05 20:11 (Fri, 19 Aug 2005 12:11:31 -0700)
From: Will Leshner

On Aug 19, 2005, at 11:31 AM, Brady Duga wrote:

> No, but it is an excellent example of bad programming style.
>

Uh, why? Is it not legal?

Re: exception bug?
Date: 19.08.05 20:13 (Fri, 19 Aug 2005 12:13:17 -0700)
From: Will Leshner

On Aug 19, 2005, at 11:31 AM, Brady Duga wrote:

> No, but it is an excellent example of bad programming style.

Anyway, I also think it is an excellent example of a bug. Which I'm
going to report unless somebody can explain to me why it isn't a bug.

Re: exception bug?
Date: 19.08.05 20:18 (Fri, 19 Aug 2005 12:18:00 -0700)
From: Will Leshner

On Aug 19, 2005, at 12:13 PM, Will Leshner wrote:

> Anyway, I also think it is an excellent example of a bug. Which I'm
> going to report unless somebody can explain to me why it isn't a bug.
>

Ok. I reread the LR and I see that my characterization of the bug is
wrong. The type is optional but if it is present, it must occur with
an argument. The syntax description in the LR is wrong, which is what
threw me. It has this:

Catch [ErrorParameter] [as ErrorType]

When it should be:

Catch [ErrorParameter [as ErrorType]]

But, there is still a bug. The compiler should flag it as a syntax
error.

Anyway, this little (one-sided) dialog has been most enlightening :)

Re: exception bug?
Date: 19.08.05 20:28 (Fri, 19 Aug 2005 12:28:11 -0700)
From: Brady Duga

On Aug 19, 2005, at 12:18 PM, Will Leshner wrote:

>
> But, there is still a bug. The compiler should flag it as a syntax
> error.

Nope. The code you wrote does not have a syntax error and behaves
exactly as I would expect. Instead of your code, try this:

try

raise new NilObjectException

catch GerbobleKerBoobleKerPlop
MsgBox "Caught a KeyNotFoundException."
catch ShnickityShnickitySchnak
MsgBox "Caught a NilObjectException."
finally
MsgBox "In try finally block."
end try

It is functionally identical to your code. Why do you think you would
see "Caught a NilObjectException."? The error, of course, is that you
gave a variable (the ErrorParameter) the same name as a class. This
is not actually illegal, but it is poor style. You can see this has
nothing to do with exception handling by doing this:

dim KeyNotFoundException as KeyNotFoundException
KeyNotFoundException = new KeyNotFoundException

This compiles just fine, but is an example of poor style.

--Brady
The La Jolla Underground

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exception bug?
Date: 19.08.05 20:30 (Fri, 19 Aug 2005 14:30:09 -0500)
From: Jonathan Johnson

On Aug 19, 2005, at 2:11 PM, Will Leshner wrote:

>
> On Aug 19, 2005, at 11:31 AM, Brady Duga wrote:
>
>> No, but it is an excellent example of bad programming style.
>>
> Uh, why? Is it not legal?

It's legal, but misleading. When you say:

try

catch IDENTIFIER

End Try

The IDENTIFIER is automatically created as a RuntimeException
variable. This stems back from how the Exception blocks worked, which
allowed you to say:

exception exc

and you could reference exc, which would contain the exception. What
makes the original example confusing, is that the variable names
chosen happen to be the same as the exception class names.

HTH,
Jon

Re: exception bug?
Date: 19.08.05 20:36 (Fri, 19 Aug 2005 12:36:39 -0700)
From: Will Leshner

On Aug 19, 2005, at 12:28 PM, Brady Duga wrote:

> It is functionally identical to your code. Why do you think you
> would see "Caught a NilObjectException."? The error, of course, is
> that you gave a variable (the ErrorParameter) the same name as a
> class. This is not actually illegal, but it is poor style. You can
> see this has nothing to do with exception handling by doing this:
>
> dim KeyNotFoundException as KeyNotFoundException
> KeyNotFoundException = new KeyNotFoundException
>
> This compiles just fine, but is an example of poor style

Very good. That does make sense.

I guess, then, that this falls back to nothing more than a
documentation error in the LR.

Re: exception bug?
Date: 19.08.05 20:37 (Fri, 19 Aug 2005 12:37:44 -0700)
From: Will Leshner

On Aug 19, 2005, at 12:30 PM, Jonathan Johnson wrote:

> The IDENTIFIER is automatically created as a RuntimeException
> variable.

Right. My confusion was thinking I could have just a type and not a
parameter that went with it. REALbasic is doing the right thing :)

Re: exception bug?
Date: 19.08.05 20:41 (Fri, 19 Aug 2005 12:41:21 -0700)
From: Brady Duga

On Aug 19, 2005, at 12:36 PM, Will Leshner wrote:
>
> I guess, then, that this falls back to nothing more than a
> documentation error in the LR.

A very minor one at that. If you say:

catch as KeyNotFoundException

You get a syntax error, even though the LR says it is legal.


--Brady
The La Jolla Underground

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exception bug?
Date: 19.08.05 20:53 (Fri, 19 Aug 2005 13:53:14 -0600)
From: Norman Palardy

On Aug 19, 2005, at 1:03 PM, Brady Duga wrote:

>
> On Aug 19, 2005, at 11:53 AM, Norman Palardy wrote:
>>
>> LOL ... he should just reach over and whack you one !
>
> Ah, but he can't - I work at home on Fridays :)

Beware of Mondays then !

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: exception bug?
Date: 19.08.05 20:58 (Fri, 19 Aug 2005 12:58:47 -0700)
From: Will Leshner

On Aug 19, 2005, at 12:41 PM, Brady Duga wrote:

> A very minor one at that. If you say:
>
> catch as KeyNotFoundException
>
> You get a syntax error, even though the LR says it is legal.

True. I assumed the documentation error was a lack of brackets around
the "as", when, in fact, it was a misplaced closing bracket.

I might point out that I could imagine an alternate syntax in which
you don't really care about the argument, but you do want to be able
to specify different catch types. Hmm. I guess the problem is that
the compiler wouldn't be able to differentiate that from the bare
argument case. So maybe the syntax I had in mind is simply not possible.

Re: exception bug?
Date: 19.08.05 20:59 (Fri, 19 Aug 2005 12:59:26 -0700)
From: Will Leshner

On Aug 19, 2005, at 12:53 PM, Norman Palardy wrote:

> Beware of Mondays then !

Nah. That's the day *I* work at home. Tuesday is a different story :)

Re: exception bug?
Date: 20.08.05 03:12 (Fri, 19 Aug 2005 22:12:37 -0400)
From: Brad Rhine
On Aug 19, 2005, at 3:59 PM, Will Leshner wrote:

>> Beware of Mondays then !
>
> Nah. That's the day *I* work at home. Tuesday is a different story :)

Ten bucks says Brady's sick on Tuesday. ;)