Ignore:
Timestamp:
05/04/2009 09:21:44 AM (3 years ago)
Author:
guyru
Message:

Re-factor the Statistics constructor to use exceptions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/statistics.cpp

    r199 r201  
    3434Statistics::Statistics(configuration::Configuration *backend) 
    3535{ 
     36        try { 
     37                load_data(); 
     38        } catch (exception &e) { 
     39                reset(); 
     40        } 
     41} 
     42 
     43void Statistics::load_data()  
     44{ 
    3645        string tmp; 
    3746        vector<string> tmp_vec; 
     
    4655        tmp = backend->get("statistics_score_distribution"); 
    4756        split(tmp_vec, tmp, is_any_of(",")); 
    48         if (tmp_vec.size() != score_distributions_slots) { 
    49                 reset(); 
    50                 return; 
    51         } 
     57        if (tmp_vec.size() != score_distributions_slots) 
     58                throw BadConfiguration(); 
    5259 
    5360        BOOST_FOREACH(string i, tmp_vec) { 
     
    5764        istringstream i(tmp); 
    5865        i >> _last_reset; 
     66        if (!_last_reset) 
     67                throw BadConfiguration(); 
     68                 
    5969} 
    6070 
Note: See TracChangeset for help on using the changeset viewer.