From 4f12a30d3ec94c78155e99046e40f07e92726db6 Mon Sep 17 00:00:00 2001 From: Antoine Lambert Date: Fri, 18 Oct 2024 20:05:58 +0200 Subject: [PATCH] plugins/ImportBibTeX: Catch all xdkbib::File::readFromFile exceptions Better having an error message when bibtex file parsing failed than crashing. --- plugins/import/BibTeX/ImportBibTeX.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/import/BibTeX/ImportBibTeX.cpp b/plugins/import/BibTeX/ImportBibTeX.cpp index 28f746715b..70f2f662d3 100644 --- a/plugins/import/BibTeX/ImportBibTeX.cpp +++ b/plugins/import/BibTeX/ImportBibTeX.cpp @@ -1,6 +1,6 @@ /** * - * Copyright (C) 2019-2023 The Talipot developers + * Copyright (C) 2019-2024 The Talipot developers * * Talipot is a fork of Tulip, created by David Auber * and the Tulip development Team from LaBRI, University of Bordeaux @@ -17,6 +17,7 @@ #include #include +#include using namespace std; using namespace tlp; @@ -344,6 +345,10 @@ class ImportBibTeX : public ImportModule { sstr << "BibTeX file parsing error at char " << e.column() << " of line " << e.line() << ": " << e.what() << endl; pluginProgress->setError(sstr.str()); + } catch (antlr::ANTLRException &e) { + pluginProgress->setError("BibTeX file could not be parsed: " + string(e.getMessage())); + } catch (exception &e) { + pluginProgress->setError("BibTeX file could not be parsed: " + string(e.what())); } result = !graph->isEmpty();