diff --git a/lemon/graph_to_eps.h b/lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h +++ b/lemon/graph_to_eps.h @@ -40,6 +40,7 @@ #include #include #include +#include ///\ingroup eps_io @@ -1166,8 +1167,13 @@ GraphToEps > graphToEps(G &g,const char *file_name) { + std::ostream* os = new std::ofstream(file_name); + if (!(*os)) { + delete os; + throw IoError(file_name, "Cannot write file"); + } return GraphToEps > - (DefaultGraphToEpsTraits(g,*new std::ofstream(file_name),true)); + (DefaultGraphToEpsTraits(g,*os,true)); } ///Generates an EPS file from a graph @@ -1182,8 +1188,13 @@ GraphToEps > graphToEps(G &g,const std::string& file_name) { + std::ostream* os = new std::ofstream(file_name.c_str()); + if (!(*os)) { + delete os; + throw IoError(file_name, "Cannot write file"); + } return GraphToEps > - (DefaultGraphToEpsTraits(g,*new std::ofstream(file_name.c_str()),true)); + (DefaultGraphToEpsTraits(g,*os,true)); } } //END OF NAMESPACE LEMON