AW: [mono-vb] Err Object & Err Numbers

Jochen Wezel jwezel@compumaster.de
Wed, 30 Jun 2004 09:12:15 +0200


Let's do that...=20


-----Urspr=FCngliche Nachricht-----
Von: mono-vb-admin@lists.ximian.com =
[mailto:mono-vb-admin@lists.ximian.com] Im Auftrag von A Rafael D =
Teixeira
Gesendet: Dienstag, 29. Juni 2004 20:53
An: kjambunathan@novell.com
Cc: mono-vb@lists.ximian.com
Betreff: RE: [mono-vb] Err Object & Err Numbers

Hi Jambunathan,

Well I did not follow it: It isn't resolved.

More: We need to make it into nunit tests for the corresponding parts in =
MS.VB.DLL, and also compiler test sources to guarantee compatible =
behaviour.

Maybe you are suggesting to open a series of more specific bug cases, to =
match smaller units of work. That is acceptable.

Just to say what we are after...

Refining the test code that Jochen has put there to something like:

<snip>
    Private Sub ThrowIt(ByVal exc As Exception)
        Try
            Throw exc
        Catch ex As Exception
            If Err.Number <> 0 Then WriteLine("ErrDescr=3D " &
Err.Description)
            If Err.Number <> 0 Then WriteLine("ErrNo=3D " & Err.Number)
            WriteLine("Exception=3D " & ex.ToString())
            WriteLine("-------------------------")
        End Try
    End Sub

    Private Sub ErrorIt(errornum as Integer)
        Try
            Err.Raise(errornum)
        Catch ex As Exception
            If Err.Number <> 0 Then WriteLine("ErrDescr=3D " &
Err.Description)
            If Err.Number <> 0 Then WriteLine("ErrNo=3D " & Err.Number)
            WriteLine("Exception=3D " & ex.ToString())
            WriteLine("-------------------------")
        End Try
    End Sub

    Private Sub ErrObjTests()
        ThrowIt(New ArgumentOutOfRangeException("blah"))  ' --> No. 5
        ThrowIt(New OverflowException)    ' --> No. 6 default =
description
        ThrowIt(New OverflowException("blah"))  ' --> No. 6
        ThrowIt(New Exception("WhatIsIt?"))  ' --> No. 5
        ErrorIt(4)
        ErrorIt(5)
        ErrorIt(6)
    End Sub
</snip>

I got the following results:
<results>
ErrDescr=3D Specified argument was out of the range of valid values.
Parameter name: blah
ErrNo=3D 5
Exception=3D System.ArgumentOutOfRangeException: Specified argument was =
out of the range of valid values.
Parameter name: blah
   at WindowsApplication1.Form1.ThrowIt(Exception exc) in =
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr=3D Arithmetic operation resulted in an overflow.
ErrNo=3D 6
Exception=3D System.OverflowException: Arithmetic operation resulted in =
an overflow.
   at WindowsApplication1.Form1.ThrowIt(Exception exc) in =
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr=3D blah
ErrNo=3D 6
Exception=3D System.OverflowException: blah
   at WindowsApplication1.Form1.ThrowIt(Exception exc) in =
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr=3D WhatIsIt?
ErrNo=3D 5
Exception=3D System.Exception: WhatIsIt?
   at WindowsApplication1.Form1.ThrowIt(Exception exc) in =
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr=3D Application-defined or object-defined error.
ErrNo=3D 4
Exception=3D System.Exception: Application-defined or object-defined =
error.
   at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, =
Object Description, Object HelpFile, Object HelpContext)
   at WindowsApplication1.Form1.ErrorIt(Int32 errornum) in =
C:\Dev\WindowsApplication1\Form1.vb:line 138
-------------------------
ErrDescr=3D Procedure call or argument is not valid.
ErrNo=3D 5
Exception=3D System.ArgumentException: Procedure call or argument is not =
valid.
   at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, =
Object Description, Object HelpFile, Object HelpContext)
   at WindowsApplication1.Form1.ErrorIt(Int32 errornum) in =
C:\Dev\WindowsApplication1\Form1.vb:line 138
-------------------------
ErrDescr=3D Overflow.
ErrNo=3D 6
Exception=3D System.OverflowException: Overflow.
   at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, =
Object Description, Object HelpFile, Object HelpContext)
   at WindowsApplication1.Form1.ErrorIt(Int32 errornum) in =
C:\Dev\WindowsApplication1\Form1.vb:line 138
-------------------------
</results>

Well I don't think mbas compiles this right yet. See, VB.NET compiler =
need to add some extra code in catch blocks to make the exception =
available in Err, vbc does this inside ThrowIt catch block

    IL_0009:  dup
    IL_000a:  call       void=20
[Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData=
::SetProjectError(class
[mscorlib]System.Exception)


So even if this same program when compiled with vbc and run in mono =
using=20
our MS.VB.DLL, won't say the right things, because I'm not sure if the=20
Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError =
method=20
is correctly implemented and interacts with the implemented ErrObject in =
the=20
proper way (I don't have access to a mono environment and/or source =
where I=20
am for the next hours so I can't check it for correctness myself).

So as it stands, please prove me wrong or reopen or decompose the bug =
case.

Also we aren't even scratching the whole mess as "On Error" processing =
isn't=20
being tackled yet. Think of the ill-conceived but common pattern among =
VB=20
developers "On Error Resume Next / do something / check Err if needed =
(after=20
the fact) / ... similar statements like the last two (n-times)"

Thanks,


Rafael "Monoman" Teixeira
Mono Hacker since 16 Jul 2001 - http://www.go-mono.org/
MonoBrasil Founding Member - Membro Fundador do MonoBrasil=20
http://monobrasil.softwarelivre.org
English Blog: http://monoblog.blogspot.com/
Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/

>From: "Jambunathan Jambunathan" <kjambunathan@novell.com>
>To: <mono-vb@lists.ximian.com>
>Subject: [mono-vb] Err Object & Err Numbers
>Date: Tue, 29 Jun 2004 09:07:41 -0600
>
>Rafael/Jochen
>
>I am marking the following
>bug:http://bugzilla.ximian.com/show_bug.cgi?id=3D52064 as resolved.
>Will appreciate your comments/feedback.
>
>Regards,
>Jambunathan K.
>_______________________________________________
>Mono-vb mailing list
>Mono-vb@lists.ximian.com
>http://lists.ximian.com/mailman/listinfo/mono-vb

_________________________________________________________________
MSN Messenger: instale grtis e converse com seus amigos.=20
http://messenger.msn.com.br

_______________________________________________
Mono-vb mailing list
Mono-vb@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-vb