Procházet zdrojové kódy

#679 Improved the reporting in case of an error while loading a module: 1) the list of already loaded modules is given, 2) the full path of the searched node is given

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2621 a333f486-631f-4898-b8df-5754b55c2be0
romainq před 12 roky
rodič
revize
d5aab1a774
1 změnil soubory, kde provedl 11 přidání a 6 odebrání
  1. 11 6
      setup/modelfactory.class.inc.php

+ 11 - 6
setup/modelfactory.class.inc.php

@@ -213,7 +213,7 @@ class ModelFactory
 				{
 					echo "Dumping target doc - looking for '$sParentId'<br/>\n";
 					$this->oDOMDocument->firstChild->Dump();
-					throw new Exception("XML datamodel loader: could not find parent node for $oSourceNode->tagName / ".$oSourceNode->getAttribute('id')." with parent id $sParentId");
+					throw new Exception("could not find parent node for $oSourceNode->tagName(id:".$oSourceNode->getAttribute('id').") with parent id $sParentId");
 				}
 			}
 			else 
@@ -223,7 +223,7 @@ class ModelFactory
 				{
 					echo "Dumping target doc - looking for '".$oSourceNode->getAttribute('id')."'<br/>\n";
 					$this->oDOMDocument->firstChild->Dump();
-					throw new Exception("XML datamodel loader: could not find node for $oSourceNode->tagName/".$oSourceNode->getAttribute('id'));
+					throw new Exception("could not find node for $oSourceNode->tagName(id:".$oSourceNode->getAttribute('id').")");
 				}
 				else
 				{
@@ -303,7 +303,7 @@ class ModelFactory
 			$sModuleName = $oModule->GetName();
 			$aClasses = array();
 			self::$aLoadedModules[] = $oModule;
-			
+		
 			// For persistence in the cache
 			$oModuleNode = $this->oDOMDocument->CreateElement('module');
 			$oModuleNode->setAttribute('id', $oModule->GetId());
@@ -356,7 +356,12 @@ class ModelFactory
 		}
 		catch(Exception $e)
 		{
-			throw new Exception('Error loading module "'.$oModule->GetName().'": '.$e->getMessage());
+			$aLoadedModuleNames = array();
+			foreach (self::$aLoadedModules as $oModule)
+			{
+				$aLoadedModuleNames[] = $oModule->GetName();
+			}
+			throw new Exception('Error loading module "'.$oModule->GetName().'": '.$e->getMessage().' - Loaded modules: '.implode(',', $aLoadedModuleNames));
 		}
 	}
 
@@ -1691,7 +1696,7 @@ class MFElement extends DOMElement
 			{
 				if ($bMustExist)
 				{
-					throw new Exception("XML datamodel loader: found mandatory node $this->tagName/$sSearchId marked as deleted in $oContainer->tagName");
+					throw new Exception("found mandatory node $this->tagName(id:$sSearchId) marked as deleted in ".$oContainer->getNodePath());
 				}
 				// Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17)
 				// So use this workaround to import a node and its attributes on *any* PHP version
@@ -1705,7 +1710,7 @@ class MFElement extends DOMElement
 			{
 				echo "Dumping parent node<br/>\n";
 				$oContainer->Dump();
-				throw new Exception("XML datamodel loader: could not find $this->tagName/$sSearchId in $oContainer->tagName");
+				throw new Exception("could not find $this->tagName(id:$sSearchId) in ".$oContainer->getNodePath());
 			}
 			// Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17)
 			// So use this workaround to import a node and its attributes on *any* PHP version