1.1 --- a/lemon/lgf_writer.h Wed Oct 01 12:44:16 2008 +0200
1.2 +++ b/lemon/lgf_writer.h Wed Oct 01 13:56:40 2008 +0200
1.3 @@ -55,7 +55,7 @@
1.4
1.5 template <typename T>
1.6 bool operator<(const T&, const T&) {
1.7 - throw DataFormatError("Label map is not comparable");
1.8 + throw FormatError("Label map is not comparable");
1.9 }
1.10
1.11 template <typename _Map>
1.12 @@ -203,7 +203,7 @@
1.13 typename std::map<Value, std::string>::const_iterator it =
1.14 _map.find(str);
1.15 if (it == _map.end()) {
1.16 - throw DataFormatError("Item not found");
1.17 + throw FormatError("Item not found");
1.18 }
1.19 return it->second;
1.20 }
1.21 @@ -223,7 +223,7 @@
1.22 typename std::map<typename Graph::Edge, std::string>
1.23 ::const_iterator it = _map.find(val);
1.24 if (it == _map.end()) {
1.25 - throw DataFormatError("Item not found");
1.26 + throw FormatError("Item not found");
1.27 }
1.28 return (_graph.direction(val) ? '+' : '-') + it->second;
1.29 }
1.30 @@ -462,7 +462,9 @@
1.31 /// output file.
1.32 DigraphWriter(const Digraph& digraph, const std::string& fn)
1.33 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
1.34 - _skip_nodes(false), _skip_arcs(false) {}
1.35 + _skip_nodes(false), _skip_arcs(false) {
1.36 + if (!(*_os)) throw IoError("Cannot write file", fn);
1.37 + }
1.38
1.39 /// \brief Constructor
1.40 ///
1.41 @@ -470,7 +472,9 @@
1.42 /// output file.
1.43 DigraphWriter(const Digraph& digraph, const char* fn)
1.44 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
1.45 - _skip_nodes(false), _skip_arcs(false) {}
1.46 + _skip_nodes(false), _skip_arcs(false) {
1.47 + if (!(*_os)) throw IoError("Cannot write file", fn);
1.48 + }
1.49
1.50 /// \brief Destructor
1.51 ~DigraphWriter() {
1.52 @@ -1019,7 +1023,9 @@
1.53 /// output file.
1.54 GraphWriter(const Graph& graph, const std::string& fn)
1.55 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
1.56 - _skip_nodes(false), _skip_edges(false) {}
1.57 + _skip_nodes(false), _skip_edges(false) {
1.58 + if (!(*_os)) throw IoError("Cannot write file", fn);
1.59 + }
1.60
1.61 /// \brief Constructor
1.62 ///
1.63 @@ -1027,7 +1033,9 @@
1.64 /// output file.
1.65 GraphWriter(const Graph& graph, const char* fn)
1.66 : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
1.67 - _skip_nodes(false), _skip_edges(false) {}
1.68 + _skip_nodes(false), _skip_edges(false) {
1.69 + if (!(*_os)) throw IoError("Cannot write file", fn);
1.70 + }
1.71
1.72 /// \brief Destructor
1.73 ~GraphWriter() {
1.74 @@ -1578,13 +1586,17 @@
1.75 ///
1.76 /// Construct a section writer, which writes into the given file.
1.77 SectionWriter(const std::string& fn)
1.78 - : _os(new std::ofstream(fn.c_str())), local_os(true) {}
1.79 + : _os(new std::ofstream(fn.c_str())), local_os(true) {
1.80 + if (!(*_os)) throw IoError("Cannot write file", fn);
1.81 + }
1.82
1.83 /// \brief Constructor
1.84 ///
1.85 /// Construct a section writer, which writes into the given file.
1.86 SectionWriter(const char* fn)
1.87 - : _os(new std::ofstream(fn)), local_os(true) {}
1.88 + : _os(new std::ofstream(fn)), local_os(true) {
1.89 + if (!(*_os)) throw IoError("Cannot write file", fn);
1.90 + }
1.91
1.92 /// \brief Destructor
1.93 ~SectionWriter() {