|
From: <di...@us...> - 2011-01-24 18:43:18
|
Revision: 13627
http://exist.svn.sourceforge.net/exist/?rev=13627&view=rev
Author: dizzzz
Date: 2011-01-24 18:43:11 +0000 (Mon, 24 Jan 2011)
Log Message:
-----------
[ignore] an other important step in try-catch
Modified Paths:
--------------
branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java
branches/adam/eXist-xq3/src/org/exist/xquery/XPathException.java
branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml
Modified: branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java
===================================================================
--- branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java 2011-01-24 18:25:09 UTC (rev 13626)
+++ branches/adam/eXist-xq3/src/org/exist/xquery/TryCatchExpression.java 2011-01-24 18:43:11 UTC (rev 13627)
@@ -116,7 +116,12 @@
// Get qname
ErrorCode errorCode = xpe.getErrorCode();
- System.out.println("aaaaa"+xpe.toString());
+ if(errorCode==null){
+ String[] data = extractLocalName(xpe.getMessage());
+ errorCode = new ErrorCode( new QName(data[0], "err"), data[1]);
+ errorCode.getErrorQName().setPrefix("err");
+ System.out.println("Results="+data[0] + "/" + data[1]);
+ }
QName errorCodeQname = errorCode.getErrorQName();
// Exception in thrown, catch expression will be evaluated.
@@ -157,14 +162,14 @@
var.setSequenceType(new SequenceType(Type.QNAME, Cardinality.EXACTLY_ONE));
QNameValue qnv = new QNameValue(context, catchVar);
// qnv.add( new StringValue("aaa") );
- var.setValue( new StringValue( xpe.getErrorCode().getErrorQName().getStringValue()) );
+ var.setValue( new StringValue( errorCode.getErrorQName().getStringValue()) );
// context.declareGlobalVariable(var);
context.declareVariable(catchVar, var);
break;
case 2:
var.setSequenceType(new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE));
- StringValue sv = new StringValue( xpe.getErrorCode().toString() );
+ StringValue sv = new StringValue( errorCode.toString() );
var.setValue(sv);
break;
case 3:
@@ -280,7 +285,16 @@
return false;
}
+ private String[] extractLocalName(String errorText)
+ throws IllegalArgumentException {
+ int p = errorText.indexOf(':');
+ if (p == Constants.STRING_NOT_FOUND)
+ return new String[]{null,errorText};
+ return new String[]{ errorText.substring(0, p).trim(), errorText.substring(p+1).trim()};
+ }
+
+
/**
* Data container
*/
Modified: branches/adam/eXist-xq3/src/org/exist/xquery/XPathException.java
===================================================================
--- branches/adam/eXist-xq3/src/org/exist/xquery/XPathException.java 2011-01-24 18:25:09 UTC (rev 13626)
+++ branches/adam/eXist-xq3/src/org/exist/xquery/XPathException.java 2011-01-24 18:43:11 UTC (rev 13627)
@@ -105,6 +105,16 @@
this.errorVal = errorVal;
}
+ // DWES : not sure?
+ public XPathException(ErrorCode errorCode, String errorDesc, Sequence errorVal) {
+ this.errorCode = errorCode;
+
+ if(errorDesc==null){
+ errorCode.toString();
+ }
+ this.errorVal = errorVal;
+ }
+
public XPathException(int line, int column, String message, Throwable cause) {
super(cause);
this.message = message;
Modified: branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml
===================================================================
--- branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml 2011-01-24 18:25:09 UTC (rev 13626)
+++ branches/adam/eXist-xq3/test/src/xquery/xq3_trycatch.xml 2011-01-24 18:43:11 UTC (rev 13627)
@@ -49,7 +49,7 @@
<!-- derived from w3c: http://www.w3.org/TR/xquery-30-use-cases/#try-catch-use-cases -->
-<!--
+
<test output="text">
<task>Usecases Q1</task>
<code><![CDATA[
@@ -67,7 +67,7 @@
</code>
<expected>An error occured, please ask your consultant for help.</expected>
</test>
- -->
+
<test output="text">
<task>Usecases Q2</task>
@@ -90,9 +90,7 @@
<expected>
<result>
<product>
- <name>broiler</name>
- Error: FORG0001
- </product>
+ <name>broiler</name>Error: err:FORG0001</product>
<product>
<name>toaster</name>
<margin>3</margin>
@@ -107,14 +105,14 @@
</product>
<product>
<name>shirt</name>
- <margin>3.3333333333333333</margin>
+ <margin>3.3333333333333335</margin>
</product>
</result>
</expected>
</test>
- <!--
-
+
+<!--
<test output="text">
<task>Usecases Q3</task>
<code><![CDATA[
@@ -151,7 +149,7 @@
-->
<!-- the following tests are derived from http://www.w3.org/TR/xquery-30/#id-try-catch -->
-<!--
+
<test output="text">
<task>A try/catch expression without a CatchErrorList catches
any error
@@ -169,7 +167,7 @@
</code>
<expected>0</expected>
</test>
-
+<!--
<test output="text">
<task>The CatchErrorList in this try/catch expression specifies
that only err:FORG0001 is caught
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|