Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

FeatureActivated and how to crash gracefully

Posted on 2013-01-22
2
Medium Priority
?
728 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 2000 total points
ID: 38805262
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 32

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses

824 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