Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

FeatureActivated and how to crash gracefully

Posted on 2013-01-22
2
Medium Priority
?
718 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

715 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