Solved

FeatureActivated and how to crash gracefully

Posted on 2013-01-22
2
663 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
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 31

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

821 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