Get last error and clear error stack trace (C#)
<script Language="c#" runat="server">
void PageLevelErrorTest()
{
// Remove opening try
int[] array = new int[9];
for(int intCounter=0; intCounter <= 9;intCounter++)
{
array[intCounter] = intCounter;
Response.Write("The value of the counter is:" + intCounter + "<br>");
}
// Remove catch and finally blocks
}
void Page_Error(object sender, EventArgs e)
{
Response.Write("Error occurred: " + Server.GetLastError().ToString());
Server.ClearError();
}
void Page_Load()
{
PageLevelErrorTest();
}
</script>
<%
Response.Write("Function call completed" + "<br>");
%>
Related examples in the same category