Changeset 540 for library/bdm/base/user_info.cpp
- Timestamp:
- 08/17/09 09:25:19 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/user_info.cpp
r493 r540 14 14 15 15 namespace bdm { 16 17 string UIException::format_message( const string &reason, const string &path ) { 18 stringstream ss; 19 ss << reason; 20 ss << " Check path \"" << path << "\"."; 21 return ss.str(); 22 } 23 16 24 ///////////////////////////// Class UIFile ///////////////////////////////////////////// 17 25 … … 132 140 133 141 if ( !result->exists ( link ) ) 134 throw UI Exception ( "linked setting was not found", potential_link);142 throw UISettingException ( "UIException: linked setting was not found.", string ( ( const char* ) potential_link ) ); 135 143 136 144 return ( *result ) [link]; … … 145 153 void UI::assert_type ( const Setting &element, Setting::Type type ) { 146 154 if ( element.getType() != type ) 147 throw UI Exception ( "wrong setting type", element );155 throw UISettingException ( "UIException: wrong setting type.", element ); 148 156 } 149 157 150 158 const Setting& UI::to_child_setting ( const Setting &element, const int index ) { 151 159 if ( !element.isList() ) 152 throw UI Exception ( "only TypeList elements could be indexed by integers", element );160 throw UISettingException ( "UIException: only TypeList elements could be indexed by integers.", element ); 153 161 154 162 return element[index]; … … 157 165 const Setting& UI::to_child_setting ( const Setting &element, const string &name ) { 158 166 if ( !element.isGroup() ) 159 throw UI Exception ( "only TypeGroup elements could be indexed by strings", element );167 throw UISettingException ( "UIException: only TypeGroup elements could be indexed by strings.", element ); 160 168 161 169 return element[name]; … … 236 244 const char* elem1 = ( const char* ) link.result[0]; 237 245 if ( ( strcmp ( elem1, "matrix" ) ) ) 238 throw UI Exception ( "the setting supposed to represent a matrix element has wrong syntax", link.result );246 throw UISettingException ( "UIException: the setting supposed to represent a matrix element has wrong syntax.", link.result ); 239 247 240 248 data_offset = 1; 241 249 } else 242 throw UI Exception ( "the setting supposed to represent a matrix element has wrong syntax", link.result );250 throw UISettingException ( "UIException: the setting supposed to represent a matrix element has wrong syntax.", link.result ); 243 251 244 252 Setting &rows_setting = link.result[0 + data_offset]; … … 254 262 255 263 if ( cols < 0 || rows < 0 ) 256 throw UI Exception ( "the dimensions of a matrix has to be non-negative", link.result );264 throw UISettingException ( "UIException: the dimensions of a matrix has to be non-negative.", link.result ); 257 265 258 266 if ( elements.getLength() != cols * rows ) 259 throw UI Exception ( "the count of the matrix elements is incompatible with matrix dimension", elements );267 throw UISettingException ( "UIException: the count of the matrix elements is incompatible with matrix dimension.", elements ); 260 268 261 269 matrix.set_size ( rows, cols ); … … 265 273 266 274 if ( !elements[0].isNumber() ) 267 throw UI Exception ( "matrix elements have to be numbers", elements[0] );275 throw UISettingException ( "UIException: matrix elements have to be numbers.", elements[0] ); 268 276 269 277 // build matrix row-wise … … 275 283 } 276 284 277 throw UI Exception ( "only numeric types or TypeList are supported as matrix values", link.result );285 throw UISettingException ( "UIException: only numeric types or TypeList are supported as matrix values.", link.result ); 278 286 } 279 287 … … 292 300 293 301 if ( matrix.cols() != 1 && matrix.rows() != 1 ) 294 throw UI Exception ( "the vector length is invalid, it seems to be rather a matrix", link.result );302 throw UISettingException ( "UIException: the vector length is invalid, it seems to be rather a matrix.", link.result ); 295 303 296 304 int len = matrix.rows() * matrix.cols(); … … 313 321 314 322 if ( !link.result[0].isNumber() ) 315 throw UI Exception ( "a vector element has to be a number", link.result[0] );323 throw UISettingException ( "UIException: a vector element has to be a number.", link.result[0] ); 316 324 317 325 for ( int i = 0; i < len; i++ ) … … 321 329 } 322 330 323 throw UI Exception ( "only numeric types, TypeArray or TypeList are supported as vector values", link.result );331 throw UISettingException ( "UIException: only numeric types, TypeArray or TypeList are supported as vector values.", link.result ); 324 332 } 325 333