aboutsummaryrefslogtreecommitdiff
path: root/src/function
diff options
context:
space:
mode:
Diffstat (limited to 'src/function')
-rw-r--r--src/function/base.h2
-rw-r--r--src/function/external_text_formatter.cc19
-rw-r--r--src/function/read_xml_file.cc18
3 files changed, 30 insertions, 9 deletions
diff --git a/src/function/base.h b/src/function/base.h
index 56712bb..3ca1d61 100644
--- a/src/function/base.h
+++ b/src/function/base.h
@@ -82,7 +82,7 @@ class FunctionBase : public xalan::Function {
const xalan::XalanDOMString& getError(
xalan::XalanDOMString& result) const {
result.assign(std::string(
- "The function expects " +
+ "The function expects " +
std::to_string(parameter_count) +
" parameter(s)"
).data());
diff --git a/src/function/external_text_formatter.cc b/src/function/external_text_formatter.cc
index 9fef439..4171ded 100644
--- a/src/function/external_text_formatter.cc
+++ b/src/function/external_text_formatter.cc
@@ -84,10 +84,21 @@ xercesc::DOMDocument* FunctionExternalTextFormatter::constructDocument(
result.setAttribute("code", std::to_string(status.exit_status()));
if ( status.exited() ) {
- result.setAttribute("result", "success");
- result.setContent(
- importDocumentElement(outputStream, domDocument)->getChildNodes()
- );
+ try {
+ result.setContent(
+ importDocumentElement(outputStream, domDocument)->getChildNodes()
+ );
+
+ result.setAttribute("result", "success");
+ }
+ catch ( const xercesc::DOMException& exception ) {
+ result.setAttribute("result", "error");
+
+ result.setValueNode(
+ "error",
+ *XercesStringGuard<char>(exception.msg)
+ );
+ }
} else {
result.setAttribute("result", "error");
}
diff --git a/src/function/read_xml_file.cc b/src/function/read_xml_file.cc
index 65989b2..e4d256d 100644
--- a/src/function/read_xml_file.cc
+++ b/src/function/read_xml_file.cc
@@ -61,11 +61,21 @@ xercesc::DOMDocument* FunctionReadXmlFile::constructDocument(
result.setAttribute("path", filePath.string());
if ( boost::filesystem::is_regular_file(filePath) ) {
- result.setAttribute("result", "success");
+ try {
+ result.setContent(
+ importDocumentElement(filePath.string(), domDocument)
+ );
- result.setContent(
- importDocumentElement(filePath.string(), domDocument)
- );
+ result.setAttribute("result", "success");
+ }
+ catch ( const xercesc::DOMException& exception ) {
+ result.setAttribute("result", "error");
+
+ result.setValueNode(
+ "error",
+ *XercesStringGuard<char>(exception.msg)
+ );
+ }
} else {
result.setAttribute("result", "error");
}