From 794fedc0dd2a4f291a0223086f978fdca94e759a Mon Sep 17 00:00:00 2001 From: Hassan Date: Wed, 27 Sep 2023 17:08:32 -0600 Subject: [PATCH] better handling of wrong filenames --- examples/Optimization/MISDP/CBF/misdp_cbf.cpp | 4 ++++ examples/Optimization/MISDP/CBF/read_misdp.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/Optimization/MISDP/CBF/misdp_cbf.cpp b/examples/Optimization/MISDP/CBF/misdp_cbf.cpp index 65859aa5..c35dd693 100644 --- a/examples/Optimization/MISDP/CBF/misdp_cbf.cpp +++ b/examples/Optimization/MISDP/CBF/misdp_cbf.cpp @@ -94,6 +94,10 @@ int main(int argc, char * argv[]){ m->add_hierarc=hierarc; auto g=CBF_read(fname.c_str(), m); + if(g.nodes.size()==0){ + cerr << "graph with size 0\n"; + return -1; + } m->print(); DebugOn("Instance "<>& m, bool add_3d) { pFile = FOPEN(file, "rt"); if (!pFile) { - throw invalid_argument("cannot open misdp data file"); + cerr <<"Cannot open misdp data file " << file << endl; + return g; } CBFdata data = { 0, }; // Keyword OBJ should exist!