Solved

FeatureActivated and how to crash gracefully

Posted on 2013-01-22
2
630 Views
Last Modified: 2013-01-25
Hello. I have nice FeatureActivated -method, but any error will crash whole page. How can I ask SharePoint to show nice exception message?

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            try 
           {
              //Error. Field does not exist etc.
            }
            catch(Exception e)
            {
                throw new SPException("xxx." + e.Message);
            }
        }

Open in new window

0
Comment
Question by:tolppa
2 Comments
 
LVL 14

Accepted Solution

by:
KoenVosters earned 500 total points
Comment Utility
http://koenvosters.wordpress.com/2009/07/31/howto-create-an-event-handler-for-sharepointmoss-2007/

public override void ItemAdding(SPItemEventProperties properties)




{




 if (properties.AfterProperties["CheckValue"].ToString() == “dontadd”)




{




 properties.ErrorMessage = string.Format(“The CheckValue column equals dontadd -> item will not be added.”);




 properties.Status = SPEventReceiverStatus.CancelWithError;




 properties.Cancel = true;



 

}



}
0
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
Comment Utility
KoenVosters: There's no error message property on the SPFeatureReceiverProperties instance?
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now