Changeset 303 in pacpusframework for trunk/src/FileLib
- Timestamp:
- Apr 8, 2014, 11:22:06 AM (11 years ago)
- Location:
- trunk/src/FileLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/FileLib/src/DbiteFile.cpp
r292 r303 38 38 typedef int8_t VariableDataSizeT; 39 39 40 DECLARE_STATIC_LOGGER("pacpus.core.DbiteFile") ;40 DECLARE_STATIC_LOGGER("pacpus.core.DbiteFile") 41 41 42 42 namespace pacpus 43 43 { 44 VariableDataSizeTag VariableDataSize;45 ReadModeTag ReadMode;46 WriteModeTag WriteMode;47 DiagnoseModeTag DiagnoseMode;44 VariableDataSizeTag VariableDataSize; 45 ReadModeTag ReadMode; 46 WriteModeTag WriteMode; 47 DiagnoseModeTag DiagnoseMode; 48 48 } 49 49 … … 115 115 LOG_ERROR("Dbite exception: " << e.what()); 116 116 close(); 117 BOOST_THROW_EXCEPTION(DbiteException("cannot open file for reading") 117 BOOST_THROW_EXCEPTION(e 118 //<< "cannot open file for reading" 118 119 << errinfo_file_name(mPath) 119 120 << errinfo_ios_base_open_mode(openmode) … … 128 129 // TODO: readAndDiagnoseHeader(); 129 130 close(); 130 BOOST_THROW_EXCEPTION(DbiteException("cannot read header") 131 BOOST_THROW_EXCEPTION(e 132 //<< "cannot read header" 131 133 << errinfo_nested_exception(copy_exception(e)) 132 134 ); … … 194 196 // TODO: readAndDiagnoseHeader(); 195 197 close(); 196 BOOST_THROW_EXCEPTION(DbiteException("cannot read header")); 198 //BOOST_THROW_EXCEPTION(DbiteException("cannot read header")); 199 throw; 197 200 } 198 201 } else { … … 343 346 checkFileOpen(); 344 347 read((char *)(&mHeader), sizeof(mHeader)); 348 // FIXME: header has good format 345 349 LOG_DEBUG("file: " << getPath()); 346 350 LOG_TRACE("header read:\n" << string(*this)); … … 824 828 string errorMessage = "file is not open"; 825 829 LOG_WARN(errorMessage); 826 BOOST_THROW_EXCEPTION(DbiteException(errorMessage .c_str())830 BOOST_THROW_EXCEPTION(DbiteException(errorMessage) 827 831 << errinfo_file_name(mPath) 832 << errinfo_api_function("open") 828 833 ); 829 834 } -
trunk/src/FileLib/test/TestFileLib.cpp
r301 r303 21 21 #include <Pacpus/kernel/Log.h> 22 22 23 #include <boost/exception/diagnostic_information.hpp> 24 #include <boost/exception/errinfo_api_function.hpp> 25 #include <boost/exception/get_error_info.hpp> 23 26 #include <boost/noncopyable.hpp> 24 27 #include <cstdio> 25 28 26 DECLARE_STATIC_LOGGER("pacpus.framework.test.FileLib") ;29 DECLARE_STATIC_LOGGER("pacpus.framework.test.FileLib") 27 30 28 31 using namespace boost; … … 31 34 32 35 struct HasExceptionMessage 33 36 : noncopyable 34 37 { 35 38 HasExceptionMessage(const string expectedMessage) … … 48 51 }; 49 52 53 template < 54 typename ErrorInfo, 55 typename E = typename ErrorInfo::error_info::value_type 56 > 57 struct HasErrorInfo 58 : noncopyable 59 { 60 HasErrorInfo(E const& expectedValue) 61 : mExpectedValue(expectedValue) 62 { 63 } 64 65 bool operator()(DbiteException const& ex) 66 { 67 LOG_INFO("diagnostic_information: " << diagnostic_information(ex)); 68 E const* value = get_error_info<ErrorInfo>(ex); 69 if (!value) { 70 return false; 71 } 72 return mExpectedValue == *value; 73 } 74 75 private: 76 E const mExpectedValue; 77 }; 78 50 79 BOOST_AUTO_TEST_SUITE(suiteBasic) 51 80 … … 150 179 (df.open("data/bad-empty-file.dbt", ReadMode)) 151 180 , DbiteException 152 , HasExceptionMessage("cannot read header") 181 // , HasExceptionMessage("cannot read data") // FIXME: cannot read header 182 , HasErrorInfo<errinfo_api_function>("open") 153 183 ); 154 184 } … … 164 194 (df.open("data/bad-incomplete-header.dbt", ReadMode)) 165 195 , DbiteException 166 , HasExceptionMessage("cannot read header")196 , HasExceptionMessage("cannot read data") // FIXME: cannot read header 167 197 ); 168 198 }
Note:
See TracChangeset
for help on using the changeset viewer.