Exception Attraction of best practices for applying level 3

I have WCF with the following three levels:

  • Service
  • Bll
  • Dll.

Can someone help me:

Which of the above levels is the best place to search for and register exceptions for the following scenario:

Scenario 1:

An exception occurs in the DLL.

Scenario: 2:

An exception occurs in the BLL.

Also, should I always always transfer a BLL call from a service to Try and Catch?

+4
source share
2 answers

it depends on your system here, but I would have registered exceptions, probably inside BLL. And remember that you will not catch the "log"! That is - at the end of the catch there will be a retron!

I donโ€™t understand anything at all in the service - itโ€™s just communication with the client - there is no need to insert any IMHO logic into it.

And, of course: catch the expected exceptions when they are thrown, and just let the incomplete pass through.

For example: Scenario 1 - it is possible to catch SqlExceptions, try to process them, and if you do not wrap them in some DAL-Exception and throw them away. Scenario 2 - perhaps catch DAL exceptions from level 3 and see if you can handle them or wrap them again, ...

IMHO, it is almost never recommended to handle, register and disable all types of exceptions ( catch (Exception) ) - after this, the state of the application will be simply undefined.

+4
source

Read some MSDN articles on Microsoft Exception Block

It goes through many scenarios and gives you some good ideas for best practices for handling exceptions, whether you use an exception handling unit or not, as shown in the diagram below.

enter image description here

+3
source

All Articles