Click here to Skip to main content
15,889,335 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionSMS forwarding through GSM modem Pin
Member 94607155-Oct-12 2:57
Member 94607155-Oct-12 2:57 
QuestionHow to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 1:13
AtALossHere5-Oct-12 1:13 
AnswerRe: How to force rendering to generate an ID? Pin
Sandeep Mewara5-Oct-12 2:24
mveSandeep Mewara5-Oct-12 2:24 
GeneralRe: How to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 3:26
AtALossHere5-Oct-12 3:26 
GeneralRe: How to force rendering to generate an ID? Pin
Sandeep Mewara5-Oct-12 3:30
mveSandeep Mewara5-Oct-12 3:30 
GeneralRe: How to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 4:51
AtALossHere5-Oct-12 4:51 
AnswerRe: How to force rendering to generate an ID? Pin
AtALossHere5-Oct-12 4:58
AtALossHere5-Oct-12 4:58 
QuestionCustom Class Exception Management / Setup Pin
M-Badger4-Oct-12 1:40
M-Badger4-Oct-12 1:40 
I'm trying to get my head around a good way to set up exception management in a custom class, if I understand some of the advice in CP articles and elsewhere correctly then something like this setup is 'a' good way:

Simplified case: A class encapsulates a 2D array and has an UpperBound property that takes a an integer and returns the UpperBound of that dimension (since it does not expose the array directly).

Rather than the UpperBound property testing that the integer is either 0 or 1, I should put the call to the array GetUpperBound(dimension) method in a Try block and catch the exceptions that can be thrown by the array method, then re-throw the exception from the encapsulating class with the array exception as the inner exception parameter. Is that smart?

Then if another method in the class uses the UpperBound property (in the encapsulating class) it should catch and re-throw the exceptions created by the UpperBound method (again with the inner exception as a parmater), hence the exception the programmer recieves has a trail directly from the methods they called through whatever path was then followed and ending up with the base exception thrown by the encapculated array.

For example:
VB
''' <summary>
''' Gets the upper bound of the specified dimension in the matrix
''' </summary>
''' <param name="dimension">A zero based dimension of the matrix. Must be zero or one since the a Matrix is two dimensional</param>
''' <value></value>
''' <returns>The upper bound of the specified dimension</returns>
''' <exception cref="IndexOutOfRangeException">This exception is thrown if the specified <paramref name="dimension"/><c> is less than zero or exceeds one, since the a Matrix is two dimensional</c></exception>
''' <remarks></remarks>
Public ReadOnly Property UpperBound(ByVal dimension As Integer) As Integer
    Get
        Try
            Return Me._matrix.GetUpperBound(dimension)
        Catch inex As IndexOutOfRangeException
            Throw New IndexOutOfRangeException("The dimension you specified is out of range for this matrix object. Matrix objects have only two dimensions, 0 and 1. See the inner exception for more detail.", inex)
        Catch ex As Exception
            Throw
        End Try
    End Get
End Property


Then if I had another method in my class (call it Iterate for example) that needed the UpperBound of the rows (dimension = 0), say to use in a For loop, it would again do this in a Try block, call the UpperBound property and catch the exceptions thrown by the UpperBound property. So if somehow this latter method (Iterate) managed to make a call to UpperBound(2) then the programmer would see the Iterate method throw an IndexOutOfRange exception with the UpperBound exception as its inner exception and that in turn would have the array GertUpperBound exception as an inner exception.

Smart, dumb - other names? Advice?

Mike
AnswerRe: Custom Class Exception Management / Setup Pin
Pete O'Hanlon4-Oct-12 1:50
mvePete O'Hanlon4-Oct-12 1:50 
GeneralRe: Custom Class Exception Management / Setup Pin
M-Badger4-Oct-12 2:27
M-Badger4-Oct-12 2:27 
GeneralRe: Custom Class Exception Management / Setup Pin
Pete O'Hanlon4-Oct-12 2:32
mvePete O'Hanlon4-Oct-12 2:32 
QuestionI need an idea for program Pin
Cihangir Giray Han3-Oct-12 22:02
Cihangir Giray Han3-Oct-12 22:02 
AnswerRe: I need an idea for program Pin
Pete O'Hanlon3-Oct-12 22:08
mvePete O'Hanlon3-Oct-12 22:08 
GeneralRe: I need an idea for program Pin
Cihangir Giray Han3-Oct-12 22:33
Cihangir Giray Han3-Oct-12 22:33 
GeneralRe: I need an idea for program Pin
Pete O'Hanlon3-Oct-12 22:39
mvePete O'Hanlon3-Oct-12 22:39 
GeneralRe: I need an idea for program Pin
Cihangir Giray Han4-Oct-12 1:47
Cihangir Giray Han4-Oct-12 1:47 
GeneralRe: I need an idea for program Pin
Pete O'Hanlon4-Oct-12 1:51
mvePete O'Hanlon4-Oct-12 1:51 
QuestionEntity Framework, Import Function Stored Procs & Data Services Pin
Worried Brown Eyes1-Oct-12 23:57
Worried Brown Eyes1-Oct-12 23:57 
QuestionHow to use FileSystemWatcher Control ? Pin
DEEPAK9489@GMAIL.COM1-Oct-12 16:47
DEEPAK9489@GMAIL.COM1-Oct-12 16:47 
AnswerRe: How to use FileSystemWatcher Control ? Pin
JF20151-Oct-12 19:05
JF20151-Oct-12 19:05 
AnswerRe: How to use FileSystemWatcher Control ? Pin
Eddy Vluggen2-Oct-12 4:42
professionalEddy Vluggen2-Oct-12 4:42 
QuestionHow to know .NET Framework, deeply? Pin
atoi_powered1-Oct-12 12:22
atoi_powered1-Oct-12 12:22 
AnswerRe: How to know .NET Framework, deeply? Pin
Eddy Vluggen2-Oct-12 4:40
professionalEddy Vluggen2-Oct-12 4:40 
GeneralRe: How to know .NET Framework, deeply? Pin
isenthil2-Oct-12 6:27
isenthil2-Oct-12 6:27 
GeneralRe: How to know .NET Framework, deeply? Pin
atoi_powered2-Oct-12 8:23
atoi_powered2-Oct-12 8:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.