Wrapping SystemException to Custom exception

Topics: Exception Handling Application Block
Jan 29, 2008 at 3:33 PM
Dear frends,
I am trying to wrap System exception to my own exception derived from application exception,but its not wrapping as expected. below is the code snippets.

web.config
<add name="DLPolicy">
<exceptionTypes>
<add type="System.DivideByZeroException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="ThrowNewException" name="DivideByZeroException">
<exceptionHandlers>
<add exceptionMessage="EBSDivideByZeroException" exceptionMessageResourceType=""
wrapExceptionType="BaseException.ebsDivideByZeroException, BaseException, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WrapHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Wrap Handler" />
</exceptionHandlers>
</add>

businessLayer:
public int PerformDivide(int _b, int _c)
{
int _a=0;
OrderDL _orderDL;
try
{
//if (_b != 0 && _c != 0)
//{
_orderDL = new OrderDL();
_a = orderDL.PerformDivide(b, _c);
return _a;
//}
//return 0;
}
catch(Exception ex)
{
return 0;
}
}

DataLayer:
internal int PerformDivide(int _b, int _c)
{
int _a;

//For DivideByZeroException
try
{
_a = _b / _c;
return _a;
}
catch(Exception ex)
{
bool rethrow = ExceptionPolicy.HandleException(ex, "DLPolicy");
if (rethrow)
{
throw;
}
return 0;
}

And lastly CustomException class

public class ebsDivideByZeroException: BaseException
{
public ebsDivideByZeroException():base()
{
}

public ebsDivideByZeroException(string errorMessage,Exception innerException)
: base(errorMessage,innerException)
{
}

public ebsDivideByZeroException(int errorCode, Exception innerException)
: base(errorCode, innerException)
{
}

}

Problem is :when dividebyzeroexception occurs in DataLayer, it throws customexception to business layer but does not wraps the system DivideByZeroException nor it displays the error message for custom exception which is "EBSDivideByZeroException".. I am sure missin something.. pls help.
Thanks