Search code examples
sharepointexceptionspsite

How to identify the SharePoint exception when trying to create a new site


Ok,

This seems stupid but I figured I would ask because there is a lot of expertise to tap into here and I will probably learn a good bit from the answers.

I have a service center panel for creating sites. If site creation fails, I would like to delete the site. EXCEPT if the exception is because another site already exists at that URL.

I currently get the following and could easily check for contained text but would like a more solid approach. (e.g. looking for an exception ID or something to this effect.)

Another site already exists at http://server:80/sites/xxxxxxxx. Delete this site before attempting to create a new site with the same URL, choose a new URL, or create a new inclusion at the path you originally specified.


Solution

  • Why don't you check to see if the site exists first before trying to create it?