[mono-vb] Err Object & Err Numbers
A Rafael D Teixeira
rafaelteixeirabr@hotmail.com
Tue, 29 Jun 2004 15:53:18 -0300
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= " &
Err.Description)
If Err.Number <> 0 Then WriteLine("ErrNo= " & Err.Number)
WriteLine("Exception= " & 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= " &
Err.Description)
If Err.Number <> 0 Then WriteLine("ErrNo= " & Err.Number)
WriteLine("Exception= " & 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= Specified argument was out of the range of valid values.
Parameter name: blah
ErrNo= 5
Exception= 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= Arithmetic operation resulted in an overflow.
ErrNo= 6
Exception= System.OverflowException: Arithmetic operation resulted in an
overflow.
at WindowsApplication1.Form1.ThrowIt(Exception exc) in
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr= blah
ErrNo= 6
Exception= System.OverflowException: blah
at WindowsApplication1.Form1.ThrowIt(Exception exc) in
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr= WhatIsIt?
ErrNo= 5
Exception= System.Exception: WhatIsIt?
at WindowsApplication1.Form1.ThrowIt(Exception exc) in
C:\Dev\WindowsApplication1\Form1.vb:line 127
-------------------------
ErrDescr= Application-defined or object-defined error.
ErrNo= 4
Exception= 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= Procedure call or argument is not valid.
ErrNo= 5
Exception= 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= Overflow.
ErrNo= 6
Exception= 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
[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
our MS.VB.DLL, won't say the right things, because I'm not sure if the
Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError method
is correctly implemented and interacts with the implemented ErrObject in the
proper way (I don't have access to a mono environment and/or source where I
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
being tackled yet. Think of the ill-conceived but common pattern among VB
developers "On Error Resume Next / do something / check Err if needed (after
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
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=52064 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 grátis e converse com seus amigos.
http://messenger.msn.com.br