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& toCatch) { cout << "Error during initialization! :\n" - << toCatch.getMessage() << "\n"; + << DOMString(toCatch.getMessage()) << "\n"; return 1; } @@ -88,9 +88,17 @@ parser->parse(xmlFile); } catch (const XMLException& toCatch) { - cout << "\nFile not found: '" << xmlFile << "'\n" - << "Exception message is: \n" - << toCatch.getMessage() << "\n" ; + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (const SAXParseException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (...) { + cout << "Unexpected Exception \n" ; return -1; } }</source> @@ -187,7 +195,7 @@ MySAXHandler::fatalError(const SAXParseException& exception) } catch (const XMLException& toCatch) { cout << "Error during initialization! :\n" - << toCatch.getMessage() << "\n"; + << DOMString(toCatch.getMessage()) << "\n"; return 1; } @@ -205,9 +213,17 @@ MySAXHandler::fatalError(const SAXParseException& exception) parser->parse(xmlFile); } catch (const XMLException& toCatch) { - cout << "\nFile not found: '" << xmlFile << "'\n" - << "Exception message is: \n" - << toCatch.getMessage() << "\n" ; + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (const SAXParseException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (...) { + cout << "Unexpected Exception \n" ; return -1; } }</source> @@ -706,7 +722,7 @@ int main (int argc, char* args[]) { } catch (const XMLException& toCatch) { cout << "Error during initialization! :\n" - << toCatch.getMessage() << "\n"; + << DOMString(toCatch.getMessage()) << "\n"; return 1; } @@ -722,10 +738,18 @@ int main (int argc, char* args[]) { parser->parse(xmlFile); } catch (const XMLException& toCatch) { - cout << "\nFile not found: '" << xmlFile << "'\n" - << "Exception message is: \n" - << toCatch.getMessage() << "\n" ; - return -1; + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (const SAXParseException& toCatch) { + cout << "Exception message is: \n" + << DOMString(toCatch.getMessage()) << "\n" ; + return -1; + } + catch (...) { + cout << "Unexpected Exception \n" ; + return -1; } return 0; -- GitLab