protected void dv_PR_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
if (e.Exception != null)
{
lbl_Errors.Text = e.Exception.Message.ToString();
e.ExceptionHandled = true;
}
else
{
Response.Redirect("~/PR/PR_Item.aspx?PR=" + tb_tPR.Text);
}
}
but then have to parse and switch() to get a meaningful message to the user.
Is there a way to use a try/catch in this situation so I can handle the
different exceptions individually?
I guess you could rethrow e.Exception in a try block and catch that, but it
may wipe the stack trace and change the exception type (haven't tried it).
Something like:
if (e.Exception != null)
{
try
{
throw e.Exception;
}
catch (StackOverflowException ex)
{
// Do stuff
}
catch (Exception ex)
{
// Do other stuff
}
}
protected void dv_PR_ItemInserted(object sender,
DetailsViewInsertedEventArgs e)
{
if (e.Exception != null)
{
try
{
throw e.Exception;
}
catch (SystemException ex)
{
lbl_Errors.Text = ex.Message.ToString();
}
catch (Exception ex)
{
lbl_Errors.Text = ex.Message.ToString();
}
finally
{
e.ExceptionHandled = true;
}
}
else
{
Response.Redirect("~/PR/PR_Item.aspx?PR=" + tb_tPR.Text);
}
}
}
"Leon Mayne" <le...@rmvme.mvps.org> wrote in message
news:D7B88F5B-C98F-40D7...@microsoft.com...
It depends on what you are expecting to be thrown. I don't think looking
through a list of exceptions will help much. You may be better off breaking
the system yourself and seeing what gets thrown by stepping into the code.