From a6b5dd38e887ebf9bd63e1a984db8af469ca668e Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Mon, 3 Dec 2001 15:50:18 +0000
Subject: [PATCH] Better sample code in programming guide.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173338 13f79535-47bb-0310-9956-ffa450edef68
---
 doc/program.xml | 50 ++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/doc/program.xml b/doc/program.xml
index 539d6347f..dfee2e97f 100644
--- a/doc/program.xml
+++ b/doc/program.xml
@@ -70,7 +70,7 @@
     }
     catch (const XMLException&amp; toCatch) {
         cout &lt;&lt; "Error during initialization! :\n"
-             &lt;&lt; toCatch.getMessage() &lt;&lt; "\n";
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n";
         return 1;
     }
 
@@ -88,9 +88,17 @@
         parser->parse(xmlFile);
     }
     catch (const XMLException&amp; toCatch) {
-        cout &lt;&lt; "\nFile not found: '" &lt;&lt; xmlFile &lt;&lt; "'\n"
-             &lt;&lt; "Exception message is: \n"
-             &lt;&lt; toCatch.getMessage() &lt;&lt; "\n" ;
+        cout &lt;&lt; "Exception message is: \n"
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n" ;
+        return -1;
+    }
+    catch (const SAXParseException&amp; toCatch) {
+        cout &lt;&lt; "Exception message is: \n"
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n" ;
+        return -1;
+    }
+    catch (...) {
+        cout &lt;&lt; "Unexpected Exception \n" ;
         return -1;
     }
 }</source>
@@ -187,7 +195,7 @@ MySAXHandler::fatalError(const SAXParseException&amp; exception)
     }
     catch (const XMLException&amp; toCatch) {
         cout &lt;&lt; "Error during initialization! :\n"
-             &lt;&lt; toCatch.getMessage() &lt;&lt; "\n";
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n";
         return 1;
     }
 
@@ -205,9 +213,17 @@ MySAXHandler::fatalError(const SAXParseException&amp; exception)
         parser->parse(xmlFile);
     }
     catch (const XMLException&amp; toCatch) {
-        cout &lt;&lt; "\nFile not found: '" &lt;&lt; xmlFile &lt;&lt; "'\n"
-             &lt;&lt; "Exception message is: \n"
-             &lt;&lt; toCatch.getMessage() &lt;&lt; "\n" ;
+        cout &lt;&lt; "Exception message is: \n"
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n" ;
+        return -1;
+    }
+    catch (const SAXParseException&amp; toCatch) {
+        cout &lt;&lt; "Exception message is: \n"
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n" ;
+        return -1;
+    }
+    catch (...) {
+        cout &lt;&lt; "Unexpected Exception \n" ;
         return -1;
     }
 }</source>
@@ -706,7 +722,7 @@ int main (int argc, char* args[]) {
     }
     catch (const XMLException&amp; toCatch) {
         cout &lt;&lt; "Error during initialization! :\n"
-             &lt;&lt; toCatch.getMessage() &lt;&lt; "\n";
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n";
         return 1;
     }
 
@@ -722,10 +738,18 @@ int main (int argc, char* args[]) {
         parser->parse(xmlFile);
     }
     catch (const XMLException&amp; toCatch) {
-        cout &lt;&lt; "\nFile not found: '" &lt;&lt; xmlFile &lt;&lt; "'\n"
-             &lt;&lt; "Exception message is: \n"
-             &lt;&lt; toCatch.getMessage() &lt;&lt; "\n" ;
-       return -1;
+        cout &lt;&lt; "Exception message is: \n"
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n" ;
+        return -1;
+    }
+    catch (const SAXParseException&amp; toCatch) {
+        cout &lt;&lt; "Exception message is: \n"
+             &lt;&lt; DOMString(toCatch.getMessage()) &lt;&lt; "\n" ;
+        return -1;
+    }
+    catch (...) {
+        cout &lt;&lt; "Unexpected Exception \n" ;
+        return -1;
     }
 
     return 0;
-- 
GitLab