Show
Ignore:
Timestamp:
08/17/09 09:25:19 (15 years ago)
Author:
vbarta
Message:

split UIException into 3

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/user_info.cpp

    r493 r540  
    1414 
    1515namespace bdm { 
     16 
     17string 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 
    1624///////////////////////////// Class UIFile ///////////////////////////////////////////// 
    1725 
     
    132140 
    133141        if ( !result->exists ( link ) ) 
    134                 throw UIException ( "linked setting was not found", potential_link ); 
     142                throw UISettingException ( "UIException: linked setting was not found.", string ( ( const char* ) potential_link ) ); 
    135143 
    136144        return ( *result ) [link]; 
     
    145153void UI::assert_type ( const Setting &element, Setting::Type type ) { 
    146154        if ( element.getType() != type ) 
    147                 throw UIException ( "wrong setting type", element ); 
     155                throw UISettingException ( "UIException: wrong setting type.", element ); 
    148156} 
    149157 
    150158const Setting& UI::to_child_setting ( const Setting &element, const int index ) { 
    151159        if ( !element.isList() ) 
    152                 throw UIException ( "only TypeList elements could be indexed by integers", element ); 
     160                throw UISettingException ( "UIException: only TypeList elements could be indexed by integers.", element ); 
    153161 
    154162        return element[index]; 
     
    157165const Setting& UI::to_child_setting ( const Setting &element, const string &name ) { 
    158166        if ( !element.isGroup() ) 
    159                 throw UIException ( "only TypeGroup elements could be indexed by strings", element ); 
     167                throw UISettingException ( "UIException: only TypeGroup elements could be indexed by strings.", element ); 
    160168 
    161169        return element[name]; 
     
    236244                        const char* elem1 = ( const char* ) link.result[0]; 
    237245                        if ( ( strcmp ( elem1, "matrix" ) ) ) 
    238                                 throw UIException ( "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 ); 
    239247 
    240248                        data_offset = 1; 
    241249                } else 
    242                         throw UIException ( "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 ); 
    243251 
    244252                Setting &rows_setting = link.result[0 + data_offset]; 
     
    254262 
    255263                if ( cols < 0 || rows < 0 ) 
    256                         throw UIException ( "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 ); 
    257265 
    258266                if ( elements.getLength() != cols * rows ) 
    259                         throw UIException ( "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 ); 
    260268 
    261269                matrix.set_size ( rows, cols ); 
     
    265273 
    266274                if ( !elements[0].isNumber() ) 
    267                         throw UIException ( "matrix elements have to be numbers", elements[0] ); 
     275                        throw UISettingException ( "UIException: matrix elements have to be numbers.", elements[0] ); 
    268276 
    269277                // build matrix row-wise 
     
    275283        } 
    276284 
    277         throw UIException ( "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 ); 
    278286} 
    279287 
     
    292300 
    293301                if ( matrix.cols() != 1 && matrix.rows() != 1 ) 
    294                         throw UIException ( "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 ); 
    295303 
    296304                int len = matrix.rows() * matrix.cols(); 
     
    313321 
    314322                if ( !link.result[0].isNumber() ) 
    315                         throw UIException ( "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] ); 
    316324 
    317325                for ( int i = 0; i < len; i++ ) 
     
    321329        } 
    322330 
    323         throw UIException ( "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 ); 
    324332} 
    325333