void Application_Error(object sender, EventArgs e) { // A server side exception was not handled. Create an incident var errorController = new ErrorLoggingController(); var incident = new Incident(); incident.OriginalErrorMessage = Server.GetLastError().Message; errorController.LogIncident(incident, Application["RavenDataController"] as RavenDataController); }
/// <summary> /// Accept an Incident object, locate a potential parent incident /// and related incidents, and save to document storeage /// </summary> /// <param name="incident">The new Incident object</param> /// <param name="dataController">Document storeage as RavenDataController</param> /// <returns>Logged Incident Id as string</returns> public string LogIncident(Incident incident, RavenDataController dataController) { // When the minimum data is missing catalog this as unserviceable then save if (incident.CanIncidentBeLogged() == false) { incident.Title = "Unspecified error!"; incident.IncidentDateTime = DateTime.Now; incident.Catalogged = false; incident.PageName = "No page name!"; var unspecifiedIncidentType = new IncidentType("Unspecified", DateTime.Now, "Error logging did not capture results", "Gather more data"); incident.IncidentType = unspecifiedIncidentType; } // Has this occurred before? Associate to parent / primary occurence var parentIncident = FindParent(incident.HashedTitle, dataController); if (string.IsNullOrEmpty(parentIncident.Id) == false) { incident.ParentIncidentId = parentIncident.Id; incident.RelatedIncidents = parentIncident.RelatedIncidents; incident.Resolved = parentIncident.Resolved; incident.Catalogged = parentIncident.Catalogged; } dataController.Save<Incident>(incident); return incident.Id; }
private Incident CreateTransitionError() { var newIncident = new Incident(); newIncident.PageName = "Transitions.aspx"; newIncident.IncidentDateTime = DateTime.Now; newIncident.CurrentDOM = "Here is the DOM stuff"; newIncident.Title = "NUnit testing generated error"; return newIncident; }