Normally the SharePoint errors are filled with messages that no user will understand followed by a correlation id. Well, the user knows there is an error, but what should he do next? It would be nice to give him some advice like try to refresh the page or anything. Therefore the SPUtility provides a nice solution. With TransferToErrorPage you can simply bring your own text into an error message. This is useful if you develop some features or custom pages or anything custom.
[sourcecode language=”csharp”]
SPUtility.TransferToErrorPage(string.Format(“Error loading List Form Page: {0}\r\n\r\nStack Trace:\r\n{1}”, ex.Message, ex.StackTrace));
//OR
SPUtility.TransferToErrorPage(“Dear User, there was an error. We apologize for that. Please refresh the page and try again.”);
[/sourcecode]
The result of the error message is like this:
Looks better right?
But keep in mind: In this case there will be nothing added to ULS no logging entry is made. So you have to add it by yourself.
..:: I LIKE SHAREPOINT ::..
Leave a Reply
You must be logged in to post a comment.