Monday, December 8, 2008

Error handling in sharepoint

Scenario:
You want to display proper Error page or Access Denied page when any error occurs in your custom code.

Access Denied error:


try{
//Code goes here
}
catch(Exception ex){
SPUtility.HandleAccessDenied(ex);
}
Transferring to Error page:

SPUtility.TransferToErrorPage("Message goes here");

Remarks:
Use TransferToErrorPage to transfer control to error page, if some code is already executing , then this may throw another error.. 'System.Thread Abort'.

Article:

0 comments: