views:

165

answers:

1

What is the best practise for returning an error of a business rule in a BLL? SHould I just raise exceptions and catch them in the presentation layer, shoudl I return some kind of object that holds any exception type info?

+1  A: 

The word "returning" is tricky here.

The primary virtue of multi-tier design is orthogonality. You should be able to call the classes in your BLL from an entirely different UI than the one you're currently using and handle logging completely differently.

If an exception is able to be handled without user intervention or notification, you should generally do so within the BLL. If the exception needs to be brought to the user's attention or logged, let it bubble up to the UI, which can implement notification and logging without building such things into the BLL.

Jekke
Its also a good idea to wrap multiple exceptions (InvalidCastException, SqlException, etc etc) in single BLL exception types (MyDatabaseException) so people using the library don't have to trap for fifteen different types of exceptions on each call.
Will