private static Exception SavingExceptionHelper(NodeData data, Exception catchedEx)
{
if (data.Id != 0)
{
var message = "The content cannot be saved.";
if (catchedEx.Message.StartsWith("Cannot insert duplicate key"))
{
message += " A content with the name you specified already exists.";
var appExc = new NodeAlreadyExistsException(message, catchedEx); // new ApplicationException(message, catchedEx);
appExc.Data.Add("NodeId", data.Id);
appExc.Data.Add("Path", data.Path);
appExc.Data.Add("OriginalPath", data.OriginalPath);
//if (catchedEx.Message.StartsWith("Cannot insert duplicate key"))
appExc.Data.Add("ErrorCode", "ExistingNode");
return(appExc);
}
return(catchedEx);
}
var head = GetNodeHead(RepositoryPath.Combine(RepositoryPath.GetParentPath(data.Path), data.Name));
if (head != null)
{
//var appExp = new ApplicationException("Cannot create new content. A content with the name you specified already exists.", catchedEx);
var appExp = new NodeAlreadyExistsException("Cannot create new content. A content with the name you specified already exists.", catchedEx);
appExp.Data.Add("Path", data.Path);
appExp.Data.Add("ErrorCode", "ExistingNode");
return(appExp);
}
return(catchedEx);
}