incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r494273 - /incubator/xap/trunk/src/xap/bridges/basic/XInclude.js
Date Tue, 09 Jan 2007 00:15:48 GMT
Author: jmargaris
Date: Mon Jan  8 16:15:47 2007
New Revision: 494273

URL: http://svn.apache.org/viewvc?view=rev&rev=494273
Log:
better error handing

Modified:
    incubator/xap/trunk/src/xap/bridges/basic/XInclude.js

Modified: incubator/xap/trunk/src/xap/bridges/basic/XInclude.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/XInclude.js?view=diff&rev=494273&r1=494272&r2=494273
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/XInclude.js (original)
+++ incubator/xap/trunk/src/xap/bridges/basic/XInclude.js Mon Jan  8 16:15:47 2007
@@ -19,6 +19,7 @@
 
 Xap.require("xap.taghandling.AbstractTagImpl");
 Xap.require("xap.xml.ParserFactory");
+Xap.require("xap.util.Exception");
 
 /**
  * @fileoverview
@@ -58,32 +59,36 @@
 }
 
 xap.bridges.basic.XInclude.prototype.requestFailed = function(url, response) {
-	//TODO handle better
-	alert("XInclude request for " + url + " failed");
+	this.getSession().handleException(new xap.util.Exception("Error loading xinclude with href
" + this.getElement().getAttribute("href")));
 }
 
 xap.bridges.basic.XInclude.prototype.requestCompleted = function(url, response) {
-	var thisElement = this.getElement();
-	var text = response.responseText;
-	var parseType = thisElement.getAttribute("parse");
-	
-	var newChild = null;
-	
-	if ("text"==parseType){
-		newChild = thisElement.ownerDocument.createTextNode(text);
+	try{
+		var thisElement = this.getElement();
+		var text = response.responseText;
+		var parseType = thisElement.getAttribute("parse");
+		
+		var newChild = null;
+		
+		if ("text"==parseType){
+			newChild = thisElement.ownerDocument.createTextNode(text);
+		}
+		else{
+			var parser = xap.xml.ParserFactory.getParser();
+	  		var document =  parser.parse( text );
+	  		newChild = document.childNodes[0];
+	  		
+	  		//TODO what about fragments? Should we handle that? spec allows it with
+	  		//xpointer, kind of ugly...
+		}
+		
+		//insert before us then remove us!
+		thisElement.parentNode.insertBefore(newChild, thisElement);
+		thisElement.parentNode.removeChild(thisElement);
 	}
-	else{
-		var parser = xap.xml.ParserFactory.getParser();
-  		var document =  parser.parse( text );
-  		newChild = document.childNodes[0];
-  		
-  		//TODO what about fragments? Should we handle that? spec allows it with
-  		//xpointer, kind of ugly...
+	catch(e){	
+		this.getSession().handleException(new xap.util.Exception("Error loading xinclude with href
" + this.getElement().getAttribute("href"), e));
 	}
-	
-	//insert before us then remove us!
-	thisElement.parentNode.insertBefore(newChild, thisElement);
-	thisElement.parentNode.removeChild(thisElement);
 }
 
 



Mime
View raw message