G
Guest
HI,
How to catch custom exception using ObjectDataSource Control.
I am calling Business Layer method through ObjectDataSource control, when
Business layer method throws exception which will be wrapped to custom
exception and thrown. I want to capture the custom exception in UI Layer.
e.g.,
UI Layer Code:
protected void Page_Load(object sender, EventArgs e)
{
try
{
ObjectDataSource1.SelectMethod = "GetAllRoles";
ObjectDataSource1.TypeName =
"Shell.BizTalk.Services.BizDashboard.BusinessLayer.RoleBL";
GridView1.DataSourceID = "ObjectDataSource1";
GridView1.DataBind();
}
catch (BizDashboardException objBizDashboardException) // want to capture Here
{
string s1 = objBizDashboardException.errorNo;
BizDashboardException.publish(objBizDashboardException);
}
catch (Exception ex)
{
string s = ex.InnerException.Message; // Always capture this exception
}
}
Business Layer Code:
public static roleData GetAllRoles()
{
roleData objRoleData = null;
try
{
int x = objRoleData.Tables[0].Rows.Count;
}
catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardException("BSC-001", objException,
objException.Message, "RoleBL-GetAllRoles", Severity.Warning);
}
return objRoleData;
}
How to catch custom exception using ObjectDataSource Control.
I am calling Business Layer method through ObjectDataSource control, when
Business layer method throws exception which will be wrapped to custom
exception and thrown. I want to capture the custom exception in UI Layer.
e.g.,
UI Layer Code:
protected void Page_Load(object sender, EventArgs e)
{
try
{
ObjectDataSource1.SelectMethod = "GetAllRoles";
ObjectDataSource1.TypeName =
"Shell.BizTalk.Services.BizDashboard.BusinessLayer.RoleBL";
GridView1.DataSourceID = "ObjectDataSource1";
GridView1.DataBind();
}
catch (BizDashboardException objBizDashboardException) // want to capture Here
{
string s1 = objBizDashboardException.errorNo;
BizDashboardException.publish(objBizDashboardException);
}
catch (Exception ex)
{
string s = ex.InnerException.Message; // Always capture this exception
}
}
Business Layer Code:
public static roleData GetAllRoles()
{
roleData objRoleData = null;
try
{
int x = objRoleData.Tables[0].Rows.Count;
}
catch (Exception objException) // Converting to Custom Exception
{
throw new BizDashboardException("BSC-001", objException,
objException.Message, "RoleBL-GetAllRoles", Severity.Warning);
}
return objRoleData;
}