COIN-OR::LEMON - Graph Library

Changeset 290:f6899946c1ac in lemon-main for lemon/lgf_writer.h


Ignore:
Timestamp:
09/30/08 20:53:18 (16 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Simplifying exceptions

  • Using asserts instead of exceptions for unitialized parameters
  • Only the IO exceptions are used in the lemon
  • DataFormatError? is renamed to FormatError?
  • The IoError? is used for file access errors
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lgf_writer.h

    r248 r290  
    5656    template <typename T>
    5757    bool operator<(const T&, const T&) {
    58       throw DataFormatError("Label map is not comparable");
     58      throw FormatError("Label map is not comparable");
    5959    }
    6060
     
    204204          _map.find(str);
    205205        if (it == _map.end()) {
    206           throw DataFormatError("Item not found");
     206          throw FormatError("Item not found");
    207207        }
    208208        return it->second;
     
    224224          ::const_iterator it = _map.find(val);
    225225        if (it == _map.end()) {
    226           throw DataFormatError("Item not found");
     226          throw FormatError("Item not found");
    227227        }
    228228        return (_graph.direction(val) ? '+' : '-') + it->second;
     
    463463    DigraphWriter(const std::string& fn, const Digraph& digraph)
    464464      : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    465         _skip_nodes(false), _skip_arcs(false) {}
     465        _skip_nodes(false), _skip_arcs(false) {
     466      if (!(*_os)) throw IoError(fn, "Cannot write file");
     467    }
    466468
    467469    /// \brief Constructor
     
    471473    DigraphWriter(const char* fn, const Digraph& digraph)
    472474      : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    473         _skip_nodes(false), _skip_arcs(false) {}
     475        _skip_nodes(false), _skip_arcs(false) {
     476      if (!(*_os)) throw IoError(fn, "Cannot write file");
     477    }
    474478
    475479    /// \brief Destructor
     
    10191023    GraphWriter(const std::string& fn, const Graph& graph)
    10201024      : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    1021         _skip_nodes(false), _skip_edges(false) {}
     1025        _skip_nodes(false), _skip_edges(false) {
     1026      if (!(*_os)) throw IoError(fn, "Cannot write file");
     1027    }
    10221028
    10231029    /// \brief Constructor
     
    10271033    GraphWriter(const char* fn, const Graph& graph)
    10281034      : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    1029         _skip_nodes(false), _skip_edges(false) {}
     1035        _skip_nodes(false), _skip_edges(false) {
     1036      if (!(*_os)) throw IoError(fn, "Cannot write file");
     1037    }
    10301038
    10311039    /// \brief Destructor
     
    15771585    /// Construct a section writer, which writes into the given file.
    15781586    SectionWriter(const std::string& fn)
    1579       : _os(new std::ofstream(fn.c_str())), local_os(true) {}
     1587      : _os(new std::ofstream(fn.c_str())), local_os(true) {
     1588      if (!(*_os)) throw IoError(fn, "Cannot write file");
     1589    }
    15801590
    15811591    /// \brief Constructor
     
    15831593    /// Construct a section writer, which writes into the given file.
    15841594    SectionWriter(const char* fn)
    1585       : _os(new std::ofstream(fn)), local_os(true) {}
     1595      : _os(new std::ofstream(fn)), local_os(true) {
     1596      if (!(*_os)) throw IoError(fn, "Cannot write file");
     1597    }
    15861598
    15871599    /// \brief Destructor
Note: See TracChangeset for help on using the changeset viewer.