C# Contract Implementations and Exceptions -


I have a BO method that requires two operations to complete its contract.

  1. Enter DB
  2. Record the message metadata with an email notification

responsible individual DAO methods for both to complete action Is handled with calls.

I do not make exceptions in my DAO, I keep them in the bow and publish them. The first call is to insert the DAO, and one can throw one of NullReferenceException or SQL exceptions. The email method uses SmtpClient.Send which can throw several exceptions.

Is it possible to stress the hair method, which tells the functionality of email only to return one type of exception, through a custom one, attribute?

To make it clear:

  public void AddSupportTicket (SupportTicketDTO ticket) {tryTicketDAO.Insert (ETS) {try}; Email.SendNotification (ticket); } Catch (Exception an exc) {...} // can throw exceptions in both ways (exception BER) {...} // Overlap I can just return the catch (exception CER) {...} / / care in a custom email exception or Detaaksepshn} about  

I, I can throw the custom to hold their catch method calls every child have an exception that I would like, but it There is another aspect of the effort that gets trapped by somebody else, and gets caught in AddSupportTicket, and The UI is to redirect an intelligent error, so I do not feel good.

How should I throw the right custom exception?

Yes, this is very possible. Enterprise Library View lifting, tucking, between the layers and exceptions things plenty to set policies as well as leaving a lot of beach, so you can handle it in the configuration. Combined with the logging application block, it is a powerful combination.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -