internal void CheckForBL2364(string when)
{
try
{
if (_pageSelection.CurrentSelection == null || _domForCurrentPage ==null)
return;
XmlElement divElement =
_domForCurrentPage.SelectSingleNodeHonoringDefaultNS("//div[contains(@class, 'bloom-page')]");
string pageDivId = divElement.GetAttribute("id");
if (pageDivId != _pageSelection.CurrentSelection.Id)
{
// Several reports indicate that this occasionally and unrepeatably happens with various call stacks.
// This code is aimed at finding out a little more about the circumstances.
try
{
Logger.WriteEvent("BL2364 failure: pageDiv is {0}", _domForCurrentPage.RawDom.OuterXml);
Logger.WriteEvent("BL2364 failure: selection div is {0}", _pageSelection.CurrentSelection.GetDivNodeForThisPage().OuterXml);
}
catch (Exception)
{
Logger.WriteEvent("Bl2364: failed to write XML of DOM and selection");
}
throw new ApplicationException(
string.Format(
"Bl-2634: at {2}, id of _domForCurrentPage ({0}) is not the same as ID of _pageSelection.CurrentSelection ({1})",
pageDivId, _pageSelection.CurrentSelection.Id, when));
}
// By comparing this with the stacks dumped when the check fails, we can hopefully tell whether the DOM or
// the Current Selection ID somehow changed, which may help partition the space we need to look in to
// solve the problem.
Logger.WriteMinorEvent(String.Format("CheckForBl2364({0}: both ids are " + _pageSelection.CurrentSelection.Id, when));
}
catch (Exception err)
{
if (err.StackTrace.Contains("DeletePage"))
Logger.WriteEvent("Trying to save a page while executing DeletePage");
Logger.WriteEvent("Error: SaveNow(): a mixup occurred in page IDs");
throw new ApplicationException("Check Inner Exception", err);//have to embed instead of just rethrow in order to preserve line number
}
}