Throw xforms-compute-exception on XPath parse errors. Bug 299280, r=aaronr+doronr, a=mkaply, NPOTB

This commit is contained in:
allan%beaufour.dk 2005-07-20 08:21:43 +00:00
Родитель b5db761ddf
Коммит da9445627b
1 изменённых файлов: 41 добавлений и 35 удалений

Просмотреть файл

@ -410,14 +410,16 @@ nsXFormsUtils::EvaluateXPath(const nsAString &aExpression,
eval->CreateExpression(aExpression,
aResolverNode,
getter_AddRefs(expression));
nsIDOMXPathResult *result = nsnull;
PRBool throwException = PR_FALSE;
if (!expression) {
const nsPromiseFlatString& flat = PromiseFlatString(aExpression);
const PRUnichar *strings[] = { flat.get() };
nsXFormsUtils::ReportError(NS_LITERAL_STRING("exprParseError"),
strings, 1, aContextNode, nsnull);
return nsnull;
}
throwException = PR_TRUE;
} else {
nsCOMPtr<nsISupports> supResult;
nsresult rv = expression->EvaluateWithContext(aContextNode,
aContextPosition,
@ -426,7 +428,6 @@ nsXFormsUtils::EvaluateXPath(const nsAString &aExpression,
nsnull,
getter_AddRefs(supResult));
nsIDOMXPathResult *result = nsnull;
if (NS_SUCCEEDED(rv) && supResult) {
/// @todo beaufour: This is somewhat "hackish". Hopefully, this will
/// improve when we integrate properly with Transformiix (XXX)
@ -448,12 +449,17 @@ nsXFormsUtils::EvaluateXPath(const nsAString &aExpression,
*aIndexesUsed = analyzer.IndexesUsed();
}
CallQueryInterface(supResult, &result); // addrefs
}
else if (rv == NS_ERROR_XFORMS_CALCUATION_EXCEPTION) {
} else if (rv == NS_ERROR_XFORMS_CALCUATION_EXCEPTION) {
const nsPromiseFlatString& flat = PromiseFlatString(aExpression);
const PRUnichar *strings[] = { flat.get() };
nsXFormsUtils::ReportError(NS_LITERAL_STRING("exprEvaluateError"),
strings, 1, aContextNode, nsnull);
throwException = PR_TRUE;
}
}
// Throw xforms-compute-exception
if (throwException) {
nsCOMPtr<nsIDOMElement> resolverElement = do_QueryInterface(aResolverNode);
nsCOMPtr<nsIModelElementPrivate> modelPriv = nsXFormsUtils::GetModel(resolverElement);
nsCOMPtr<nsIDOMNode> model = do_QueryInterface(modelPriv);