[Libreoffice-commits] core.git: i18npool/source

Stephan Bergmann sbergman at redhat.com
Wed Apr 24 06:16:33 PDT 2013


 i18npool/source/localedata/saxparser.cxx |   67 ++++++++++++++-----------------
 1 file changed, 32 insertions(+), 35 deletions(-)

New commits:
commit 52b23b98a41aa78afa61c49179d10afee3f37643
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Apr 24 15:16:02 2013 +0200

    Print message of uncaught UNO exceptions
    
    Change-Id: I6a716efe28086da983a40c550613e3d8e0bd8283

diff --git a/i18npool/source/localedata/saxparser.cxx b/i18npool/source/localedata/saxparser.cxx
index 2715867..60ab16b 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: */


More information about the Libreoffice-commits mailing list