Custom exception classes

  • Thread starter Thread starter Andy B.
  • Start date Start date
A

Andy B.

I have different entities in the sql server 2008 database. The stored
procedures return certain status codes depending on the state of the
requested action or current state of the entity acted on. This is what I
have: record not found, matching records found, empty result set, invalid
entity (client only), update/insert/delete failure. How would I create
exception classes for these? Mainly, what would the best names for them be?
 
VB.NET and C# code:


Namespace MyCompany.MyApplication.BusinessLogic.Exceptions
<Serializable()> _
Public Class RecordNotFoundException
Inherits System.Exception


Public Sub New()
MyBase.New("A RecordNotFoundException has occurred")
End Sub 'New



Public Sub New(message As String)
MyBase.New(message)
End Sub 'New



Public Sub New(message As String, innerException As Exception)
MyBase.New(message, innerException)
End Sub 'New
End Class 'RecordNotFoundException
End Namespace 'MyCompany.MyApplication.BusinessLogic.Exceptions






namespace MyCompany.MyApplication.BusinessLogic.Exceptions
{
[Serializable()]
public class RecordNotFoundException : System.Exception
{

public RecordNotFoundException()
: base("A RecordNotFoundException has occurred")
{
}


public RecordNotFoundException(string message)
: base(message)
{
}


public RecordNotFoundException(string message, Exception
innerException)
: base(message, innerException)
{
}


}
}
 
Back
Top