diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-04-24 15:16:02 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-04-24 15:16:02 +0200 |
commit | 52b23b98a41aa78afa61c49179d10afee3f37643 (patch) | |
tree | af6e5db101f9835a37e9d5b1deafacdee1ef9ee7 /i18npool | |
parent | f0c5abd188641672674563fc8fa755833196bda2 (diff) |
Print message of uncaught UNO exceptions
Change-Id: I6a716efe28086da983a40c550613e3d8e0bd8283
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/localedata/saxparser.cxx | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/i18npool/source/localedata/saxparser.cxx b/i18npool/source/localedata/saxparser.cxx index 2715867f43cc..60ab16b36b75 100644 --- a/i18npool/source/localedata/saxparser.cxx +++ b/i18npool/source/localedata/saxparser.cxx @@ -17,7 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "sal/config.h" +#include <cstdlib> +#include <iostream> #include <stdio.h> #include <string.h> #include <stack> @@ -296,52 +299,46 @@ public: SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) { + try { + if( argc < 4) { + printf( "usage : %s <locaLe> <XML inputfile> <destination file>\n", argv[0] ); + exit( 1 ); + } + Reference< XComponentContext > xContext( + defaultBootstrap_InitialComponentContext()); - if( argc < 4) { - printf( "usage : %s <locaLe> <XML inputfile> <destination file>\n", argv[0] ); - exit( 1 ); - } - - Reference< XComponentContext > xContext( - defaultBootstrap_InitialComponentContext()); - - //-------------------------------- - // parser demo - // read xml from a file and count elements - //-------------------------------- - Reference< XParser > rParser = Parser::create(xContext); + //-------------------------------- + // parser demo + // read xml from a file and count elements + //-------------------------------- + Reference< XParser > rParser = Parser::create(xContext); - int nError = 0; - // create and connect the document handler to the parser - TestDocumentHandler *pDocHandler = new TestDocumentHandler( argv[1], argv[3]); + int nError = 0; + // create and connect the document handler to the parser + TestDocumentHandler *pDocHandler = new TestDocumentHandler( argv[1], argv[3]); - Reference < XDocumentHandler > rDocHandler( (XDocumentHandler *) pDocHandler ); - Reference< XEntityResolver > rEntityResolver( (XEntityResolver *) pDocHandler ); + Reference < XDocumentHandler > rDocHandler( (XDocumentHandler *) pDocHandler ); + Reference< XEntityResolver > rEntityResolver( (XEntityResolver *) pDocHandler ); - rParser->setDocumentHandler( rDocHandler ); - rParser->setEntityResolver( rEntityResolver ); + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); - // create the input stream - InputSource source; - source.aInputStream = createStreamFromFile( argv[2] ); - source.sSystemId = OUString::createFromAscii( argv[2] ); + // create the input stream + InputSource source; + source.aInputStream = createStreamFromFile( argv[2] ); + source.sSystemId = OUString::createFromAscii( argv[2] ); - try - { // start parsing rParser->parseStream( source ); - } - catch( const Exception & e ) - { - OString o1 = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8 ); - printf( "Exception during parsing : %s\n" , o1.getStr() ); - exit(1); - } - nError = pDocHandler->nError; + nError = pDocHandler->nError; - return nError; + return nError; + } catch (css::uno::Exception & e) { + std::cerr << "ERROR: " << e.Message << '\n'; + return EXIT_FAILURE; + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |