Search This Blog

Thursday, March 12, 2015

Error Handling in Sharepoint 2010 via Programming (Object Model)


SharePoint exceptions are derived from the SPException class.


Below code gives you example for write error logging details to the SharePoint Unified Logging Service (ULS) logs.


void ErrorEntry()
{

        try
        {
             //Development code

        }
       catch (Exception ex)
       {
             SPDiagnosticsCategory diagnosticsCat = new SPDiagnosticsCategory("categoryName" ,  TraceSeverity.Monitorable ,EventSeverity.Error);

SPDiagnosticsService.Local.WriteEvent(1 , diagnosticsCat , EventSeverity.Error , "Error Message" , ex.StackTrace);

       }
}

No comments:

Post a Comment