lemon/error.h
changeset 1779 f6cafba4dbf2
parent 1536 308150155bb5
child 1785 606178a14011
equal deleted inserted replaced
1:2463ae59a300 2:2f076dff977e
   322     virtual const char* exceptionName() const {
   322     virtual const char* exceptionName() const {
   323       return "lemon::DataFormatError";
   323       return "lemon::DataFormatError";
   324     }
   324     }
   325 
   325 
   326     virtual ~DataFormatError() throw() {}
   326     virtual ~DataFormatError() throw() {}
       
   327   };
       
   328 
       
   329   ///\e 
       
   330   class FileOpenError : public IOError {
       
   331   protected:
       
   332     ExceptionMember<std::string> _file;
       
   333 
       
   334     mutable ExceptionMember<std::string> _message_holder;
       
   335   public:
       
   336 
       
   337     FileOpenError(const FileOpenError &foe) : 
       
   338       IOError(foe), _file(foe._file) {}
       
   339 
       
   340     ///\e 
       
   341     explicit FileOpenError(const std::string& file)
       
   342       : _file(file) {}
       
   343 
       
   344 
       
   345     ///\e 
       
   346     void file(const std::string &file) { _file.set(file); }
       
   347  
       
   348     /// \brief Returns the filename.
       
   349     ///
       
   350     /// Returns \e null if the filename was not specified.
       
   351     const char* file() const {
       
   352       if (_file.valid() && !_file.get().empty()) {
       
   353 	return _file.get().c_str();
       
   354       } else {
       
   355 	return 0;
       
   356       }
       
   357     }
       
   358 
       
   359     ///\e 
       
   360     virtual const char* what() const throw() {
       
   361       try {
       
   362 	std::ostringstream ostr;
       
   363 	ostr << exceptionName() << ": ";
       
   364 	ostr << "Cannot open file - " << file();
       
   365 	_message_holder.set(ostr.str());
       
   366       }
       
   367       catch (...) {}
       
   368       if( _message_holder.valid()) return _message_holder.get().c_str();
       
   369       return exceptionName();
       
   370     }
       
   371 
       
   372     virtual const char* exceptionName() const {
       
   373       return "lemon::FileOpenError";
       
   374     }
       
   375 
       
   376     virtual ~FileOpenError() throw() {}
   327   };
   377   };
   328 
   378 
   329   class IOParameterError : public LogicError {
   379   class IOParameterError : public LogicError {
   330   protected:
   380   protected:
   331     ExceptionMember<std::string> _message;
   381     ExceptionMember<std::string> _message;