Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am looking to develop an error handling strategy for a SharePoint solution that makes use of sandboxed webparts. I was initially looking at a general exception handling approach based on this article, but this doesn't work for sandboxed webparts. Once an unhandled exception has been thrown in the sandbox, the user code service appears to take control, so that the exception handling in the base web part isn't reached. Are there any established error handling approaches for sandboxed solutions?

Is anyone aware of a method of determining when an unhandled exception has been thrown in a sandboxed webpart, if only to change the displayed error message to a more user friendly message?

Thanks, MagicAndi.

share|improve this question
add comment

2 Answers 2

Here's a link to an article that I found useful when writing an Office365 web part where debugging is virtually impossible.

MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications

share|improve this answer
1  
Ian, a bit tangential to the error handling, but very useful all the same. Thanks & +1 –  MagicAndi Apr 24 '12 at 10:08
add comment

I've approached this problem by catching very broad exceptions (e.g. "Exception") in my own code. It's far from ideal, though, and Code Analysis whinges the first time I compile about catching Exception being a bad pattern.

Not a brilliant answer (essentially, "handle all exceptions") but it seems to work okay, and it was because I wanted a better error message for the user too.

share|improve this answer
    
Andy, thanks for your answer. +1 Poor form on Microsoft's part for forcing us to use this approach, assuming an alternative doesn't exist. –  MagicAndi Apr 24 '12 at 10:00
1  
Wait until you start looking at trying to log those exceptions in a Sandbox-only environment (e.g. Office 365). That's really fun... –  Andy Burns Apr 24 '12 at 10:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.