COIN-OR::LEMON - Graph Library

Changeset 209:765619b7cbb2 in lemon-1.0 for lemon/error.h


Ignore:
Timestamp:
07/13/08 20:51:02 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Apply unify-sources.sh to the source tree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/error.h

    r108 r209  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
     
    4646    ExceptionMember() throw() {
    4747      try {
    48         ptr.reset(new Type());
     48        ptr.reset(new Type());
    4949      } catch (...) {}
    5050    }
     
    5252    ExceptionMember(const Type& type) throw() {
    5353      try {
    54         ptr.reset(new Type());
    55         if (ptr.get() == 0) return;
    56         *ptr = type;
     54        ptr.reset(new Type());
     55        if (ptr.get() == 0) return;
     56        *ptr = type;
    5757      } catch (...) {}
    5858    }
     
    6060    ExceptionMember(const ExceptionMember& copy) throw() {
    6161      try {
    62         if (!copy.valid()) return;
    63         ptr.reset(new Type());
    64         if (ptr.get() == 0) return;
    65         *ptr = copy.get();
     62        if (!copy.valid()) return;
     63        ptr.reset(new Type());
     64        if (ptr.get() == 0) return;
     65        *ptr = copy.get();
    6666      } catch (...) {}
    6767    }
     
    7070      if (ptr.get() == 0) return;
    7171      try {
    72         if (!copy.valid()) return;
    73         *ptr = copy.get();
     72        if (!copy.valid()) return;
     73         *ptr = copy.get();
    7474      } catch (...) {}
    7575    }
     
    7878      if (ptr.get() == 0) return;
    7979      try {
    80         *ptr = type;
     80        *ptr = type;
    8181      } catch (...) {}
    8282    }
     
    110110    bool init() throw() {
    111111      try {
    112         buf.reset(new std::ostringstream);
     112        buf.reset(new std::ostringstream);
    113113      }
    114114      catch(...) {
    115         buf.reset();
     115        buf.reset();
    116116      }
    117117      return buf.get();
     
    143143
    144144      try {
    145         *buf << t;
     145        *buf << t;
    146146      }
    147147      catch(...) {
    148         buf.reset();
     148        buf.reset();
    149149      }
    150150      return *this;
     
    157157      const char* mes = 0;
    158158      try {
    159         mes = buf->str().c_str();
     159        mes = buf->str().c_str();
    160160      }
    161161      catch(...) {}
     
    255255    ///\e
    256256    DataFormatError(const std::string &file_name, int line_num,
    257                     const char *the_message)
     257                    const char *the_message)
    258258      : _message(the_message), _line(line_num) { file(file_name); }
    259259
     
    270270    const char* message() const {
    271271      if (_message.valid() && !_message.get().empty()) {
    272         return _message.get().c_str();
     272        return _message.get().c_str();
    273273      } else {
    274         return 0;
     274        return 0;
    275275      }
    276276    }
     
    281281    const char* file() const {
    282282      if (_file.valid() && !_file.get().empty()) {
    283         return _file.get().c_str();
     283        return _file.get().c_str();
    284284      } else {
    285         return 0;
    286       }
    287     }
    288 
    289     ///\e
    290     virtual const char* what() const throw() {
    291       try {
    292         std::ostringstream ostr;
    293         ostr << "lemon:DataFormatError" << ": ";
    294         if (message()) ostr << message();
    295         if( file() || line() != 0 ) {
    296           ostr << " (";
    297           if( file() ) ostr << "in file '" << file() << "'";
    298           if( file() && line() != 0 ) ostr << " ";
    299           if( line() != 0 ) ostr << "at line " << line();
    300           ostr << ")";
    301         }
    302         _message_holder.set(ostr.str());
     285        return 0;
     286      }
     287    }
     288
     289    ///\e
     290    virtual const char* what() const throw() {
     291      try {
     292        std::ostringstream ostr;
     293        ostr << "lemon:DataFormatError" << ": ";
     294        if (message()) ostr << message();
     295        if( file() || line() != 0 ) {
     296          ostr << " (";
     297          if( file() ) ostr << "in file '" << file() << "'";
     298          if( file() && line() != 0 ) ostr << " ";
     299          if( line() != 0 ) ostr << "at line " << line();
     300          ostr << ")";
     301        }
     302        _message_holder.set(ostr.str());
    303303      }
    304304      catch (...) {}
     
    334334    const char* file() const {
    335335      if (_file.valid() && !_file.get().empty()) {
    336         return _file.get().c_str();
     336        return _file.get().c_str();
    337337      } else {
    338         return 0;
    339       }
    340     }
    341 
    342     ///\e
    343     virtual const char* what() const throw() {
    344       try {
    345         std::ostringstream ostr;
    346         ostr << "lemon::FileOpenError" << ": ";
    347         ostr << "Cannot open file - " << file();
    348         _message_holder.set(ostr.str());
     338        return 0;
     339      }
     340    }
     341
     342    ///\e
     343    virtual const char* what() const throw() {
     344      try {
     345        std::ostringstream ostr;
     346        ostr << "lemon::FileOpenError" << ": ";
     347        ostr << "Cannot open file - " << file();
     348        _message_holder.set(ostr.str());
    349349      }
    350350      catch (...) {}
     
    382382    const char* message() const {
    383383      if (_message.valid()) {
    384         return _message.get().c_str();
     384        return _message.get().c_str();
    385385      } else {
    386         return 0;
     386        return 0;
    387387      }
    388388    }
     
    393393    const char* file() const {
    394394      if (_file.valid()) {
    395         return _file.get().c_str();
     395        return _file.get().c_str();
    396396      } else {
    397         return 0;
    398       }
    399     }
    400 
    401     ///\e
    402     virtual const char* what() const throw() {
    403       try {
    404         std::ostringstream ostr;
    405         if (message()) ostr << message();
    406         if (file()) ostr << "(when reading file '" << file() << "')";
    407         _message_holder.set(ostr.str());
     397        return 0;
     398      }
     399    }
     400
     401    ///\e
     402    virtual const char* what() const throw() {
     403      try {
     404        std::ostringstream ostr;
     405        if (message()) ostr << message();
     406        if (file()) ostr << "(when reading file '" << file() << "')";
     407        _message_holder.set(ostr.str());
    408408      }
    409409      catch (...) {}
Note: See TracChangeset for help on using the changeset viewer.