This a code of Exception:
Imports Zestad.Common.V alidation
Namespace Exceptions
''' <summary>
''' Occurs if one or more business rules validation breaks
''' </summary>
<Serializable() _
Public Class ValidationExcep tion : Inherits Exception
Private varErrors As List(Of ValidationError )
''' <summary>
''' List of validation errors
''' </summary>
Public ReadOnly Property Errors() As List(Of ValidationError )
Get
Return varErrors
End Get
End Property
Private varTestProperty As string
''' <summary>
''' This is a test property for test catching and showing in the visualizer
''' </summary>
Public ReadOnly Property TestProperty() As string
Get
Return varTestProperty
End Get
End Property
''' <summary>
''' Constructor of this class
''' </summary>
Public Sub New(ByVal Message As String, Test as string, ByVal Errors As List(Of ValidationError ))
MyBase.New(Mess age)
Me.varErrors = Errors
Me.varTestPrope rty=Test
End Sub
''' <summary>
''' Returns bulleted string with error descriptions
''' </summary>
Public Overloads Function ToString(Option al ByVal Bullet As String = "", Optional ByVal IncludeMessage As Boolean = False) As String
If Me.Errors.Count = 0 Then Return ""
Dim ErrorsArray(Me. Errors.Count) As String
For i As Integer = 0 To Me.Errors.Count - 1
ErrorsArray(i) = Bullet & Me.Errors(i).Ca use
Next
If IncludeMessage = True Then
Return Me.Message & StrDup(1, Chr(13) & Chr(10)) & Join(ErrorsArra y, Chr(13) & Chr(10))
Else
Return Join(ErrorsArra y, Chr(13) & Chr(10))
End If
End Function
End Class
End Namespace
And this is a block catch:
try
....some_code.. .
throw new ValidationExcep tion ("test_message" , "test_property_ value", varErrors)
....
catch ex as ValidationExcep tion
throw ex ' visualizer shows only properties of parent class (Exception), but not ValidationExcep tion
end try
"singhhome" <si*******@gmai l.comсообщ ил/сообщил в новостя следующ е: news:11******** **************@ 73g2000cwn.goog legroups.com...
>I tried it on my system and it was showing new properties in the
visualizer!
can u send ur code of mycustomexcepti on?
Regards,
Stanislaw Tristan wrote:
>Yes, of cource, MyCustomExcepti on
" It should work!!!.
>
you are trying to use the viewer in catch() statement? is your catch
statement declared the exception object of Type MyCustomExcepti on?
//catch(MyCustomE xception ex)
//and not
catch(Exception ex)
Regards,
Stanislaw Tristan wrote:
Problem:
I created a custom exception that inherits from Exception and added a
some
of new properties. All new properties filled in the constructors. When I
throwing this custom exception and go to the snapshot viewer the last
shows
only properties of Exceptions, the new properties are not shown.
Question:
How to show new properties of Exception-descendants in the snapshot
viewer
(such as, for example, SqlException shows Procedure, Line and etc.)?