ClaySys AppForms V 1.0
An exception is an error or failure that occurs when a program is executing. Generally, an exception describes an event that was unexpected. For example, an exception will occur if a program requests more memory than the operating system can provide. This error is known as an Out of Memory Exception.
The Exception Class Hierarchy in C#
When an exception occurs normal processing of the code ceases immediately. An object is then generated that contains information relating to the error. This object is an instance of an Exception class. The most basic of the exception classes is System.Exception, the Exception class defined in an Exception the Systemnamespace.
The exception classes are organized into a hierarchy with Exception at the top. Beneath the basic Exception class are two further classes, SystemException and ApplicationException, both in the System Namespace. The SystemException class has further derived subclasses, each representing a specific type of exception that can be raised in response to a system error. The ApplicationException class is a base class from which custom application exceptions may be derived.
The exceptions will be handled only from the View layers; in case of an inner exception it will be thrown to the view and handled from there. There can be performance related issues if we bubble up the exceptions in each layer.
The general form try-catch-finally in C# is shown below:
try
{
// Statement which can cause an exception.
}
catch(Type x)
{
// Statements for handling the exception
}
finally
{
//Any cleanup code
}
In the ClaySys AppForms application, the exceptions will be logged into
1. Event Log
The event log will be used for Error logging by the ASP.net applications and the WFC application. This is to ensure that the server side errors logged to the event log of the server which threw the exception. These exceptions will also be saved to the SQL Table.
2. Log to a SQL Table
All the exceptions (including server side exceptions) will be saved to an error log table from the ClaySys AppForms Silverlight application. In case of an exception on the server code, after the exception is logged to the event log, the exception details will be returned in the format of an xml as follows:
<Error>
<Status>Error/Success</Status>
<Source>System.Data.OLEEBConnection</Source>
<Message>An Error occurred while connecting to the Database</Message>
<StackTrace>at System.ServiceModel.AsyncResult.End[TAsyncResult](IAs…..</StackTrace>
</Error>
The Exception details will be sent to the client, from where we will be appending all the attributed that caused this issue, which will be saved to Silverlight isolated storage, and a background process will be used to move the data to the server. This XML will be sent to the error tracking table for further investigation on the reason for the exception.
If you want to log exceptions occurred on the client-side to the server-side you need to add a Service which can take the exception message and store it. Silverlight supports different ways of passing data to the server. For example, Web Service, WCF Service, Service operation via WCF RIA Services or just passing data to an ASP.NET Web Form etc.
When an exception occurs in the Windows OS we will see a dialog with the exception and also detailed information. The error message to be logged will be shown in a ChildWindow when an exception occurs, for example a window like this:
There will be a user friendly message displayed to the user; if they need more details they can view the exception details. The exception details window is configuration based so, if the administrator do not want the end user to see the actual stack trace, or any other details, they can hide them.
If the user clicks on Send, the exception details will be sent to the server, which will insert the details to the exception log table. If the service fails, the exception details will be saved to the Isolated Storage of Silverlight plug-in in the browser. The application will try to save the details next time when the user logs in to the application. The flow of the exception management is as follows:
The administrator user will just have to go to the error log view in ClaySys AppForms to identify the issue reported to the end user.
Get Started with our Appforms Development Services
2024-09-13 15:39:50