From 236994673157c0e6146a1aecabd2a0baee63d93d Mon Sep 17 00:00:00 2001 From: Ko van der Sloot Date: Wed, 13 Nov 2019 15:43:36 +0100 Subject: [PATCH] don't crash on 'empty' documents. should fix https://github.com/LanguageMachines/foliautils/issues/37 --- src/FoLiA-2text.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/FoLiA-2text.cxx b/src/FoLiA-2text.cxx index 3c269ab..844cb76 100644 --- a/src/FoLiA-2text.cxx +++ b/src/FoLiA-2text.cxx @@ -166,9 +166,18 @@ int main( int argc, char *argv[] ){ } } else { - ofstream os( outname ); - UnicodeString us = d->text( class_name,retaintok); - os << us << endl; + UnicodeString us; + try { + UnicodeString us = d->text( class_name, retaintok); + } + catch( ... ){ + cout << "document '" << docName << "' contains no text in class=" + << class_name << endl; + } + if ( !us.isEmpty() ){ + ofstream os( outname ); + os << us << endl; + } #pragma omp critical { cout << "Processed :" << docName << " into " << outname