hi..
I have 3-tier application, and i want to use Exception Handling Application Block in this application, and i try to figure it out how to implement it. So, i try to create the exceptions policies and their exception types, and i rely on this process: on dataLayer i catch the exception and throw the original excption, in businessLayer or inherited class i catch the exception and wrap/replace the original exception, on UI layer i notice the client with the exception, and logging it. and i think i have architectural problem with the policies and their exceptions types. So, i have the following questions:
1. Do i have to create policy to each tier?
2. Within each policy, if i want to catch specific error, and handle it differentlly, do i need to add the exceptions type to the policy for the specific error that i want to catch, or i catch it in the code?
I mean: let say i have the policy: "dataLayer policy", and this policy contain two types of exceptions: System.Text.DecoderFallBackException and System.Exception. now, i want to catch the System.Text.DecoderFallBackException and replace it with friendlly error.
so, i throw it from the dataLayer and catch it in the caller function(on the business layer), so, do i need to write the same catch block with the same policy(the preceding code below), or, do i have put another policy to the business layer, that catch also the same errors, to replace it their and throw new exception to the UI layer?
the catch block:
try
{
// TODO: Handle exceptions
}
catch (Exception ex)
{
bool rethrow = ExceptionPolicy.HandleException(ex, "dataLayer policy");
if (rethrow)
throw;
}
3. if i want to handle the System.Text.DecoderFallBackException do i need to catch it in the code:
catch (System.Text.DecoderFallBackException ex)
{
bool rethrow = ExceptionPolicy.HandleException(ex, "dataLayer policy");
if (rethrow)
throw;
}
or, is it enough to have it as exception type in the policy?
thank you....