[Positioning] Delete several exception classes
Create exceptions bad_configuration and missing_configuration and delete all configuration-specific exceptions.
This commit is contained in:
parent
a9ac8616e8
commit
f85c7113ab
|
@ -41,7 +41,8 @@ Input::~Input()
|
|||
void Input::initialise_input_medium()
|
||||
{
|
||||
if (! Configuration::is_configured("input.medium"))
|
||||
throw no_input_medium() ;
|
||||
throw missing_configuration(
|
||||
"No input medium specified in configuration!") ;
|
||||
|
||||
const string &medium_name =
|
||||
Configuration::string_value("input.medium") ;
|
||||
|
@ -49,13 +50,15 @@ void Input::initialise_input_medium()
|
|||
if (medium_name == "CSV")
|
||||
{
|
||||
if (! Configuration::is_configured("input.csv-file"))
|
||||
throw no_input_csv_file() ;
|
||||
throw missing_configuration(
|
||||
"No input CSV file specified in the configuration!") ;
|
||||
medium = new
|
||||
InputCSV(Configuration::string_value("input.csv-file")) ;
|
||||
}
|
||||
|
||||
else
|
||||
throw input_medium_type_unknown(medium_name) ;
|
||||
throw bad_configuration(
|
||||
"The specified input medium « "+ medium_name +" » is unknown!") ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,7 +80,9 @@ void Input::initialise_log_media()
|
|||
initialise_log_csv() ;
|
||||
|
||||
else
|
||||
throw input_medium_type_unknown(*i) ;
|
||||
throw bad_configuration(
|
||||
"The input medium « "+ *i +
|
||||
" » specified for request logging is unknown!") ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +90,8 @@ void Input::initialise_log_media()
|
|||
void Input::initialise_log_csv()
|
||||
{
|
||||
if (! Configuration::is_configured("log.csv-file"))
|
||||
throw no_log_csv_file() ;
|
||||
throw missing_configuration(
|
||||
"No log CSV file specified in the configuration!") ;
|
||||
|
||||
log_media.push_back(
|
||||
new InputLogCSV(
|
||||
|
|
|
@ -35,7 +35,9 @@ void InputDataReader::initialise_topology_media()
|
|||
initialise_topology_csv() ;
|
||||
|
||||
else
|
||||
throw topology_input_medium_type_unknown(*i) ;
|
||||
throw bad_configuration(
|
||||
"The specified topology input medium « "+ *i +
|
||||
" » is unknown!") ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,10 +45,12 @@ void InputDataReader::initialise_topology_media()
|
|||
void InputDataReader::initialise_topology_csv()
|
||||
{
|
||||
if (! Configuration::is_configured("data-input.areas-csv-file"))
|
||||
throw no_topology_input_csv_file("areas") ;
|
||||
throw missing_configuration(
|
||||
"No topology input CSV file specified for areas") ;
|
||||
|
||||
if (! Configuration::is_configured("data-input.waypoints-csv-file"))
|
||||
throw no_topology_input_csv_file("waypoints") ;
|
||||
throw missing_configuration(
|
||||
"No topology input CSV file specified for waypoints") ;
|
||||
|
||||
TopologyReaderCSV(
|
||||
Configuration::string_value("data-input.areas-csv-file"),
|
||||
|
|
|
@ -54,7 +54,8 @@ void Output::initialise_output_media()
|
|||
initialise_output_csv() ;
|
||||
|
||||
else
|
||||
throw output_medium_type_unknown(*i) ;
|
||||
throw bad_configuration(
|
||||
"The specified output medium « "+ *i +" » is unknown!") ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,8 @@ void Output::initialise_output_terminal()
|
|||
void Output::initialise_output_csv()
|
||||
{
|
||||
if (! Configuration::is_configured("output.csv-file"))
|
||||
throw no_output_csv_file() ;
|
||||
throw missing_configuration(
|
||||
"No output CSV file specified in the configuration!") ;
|
||||
|
||||
output_media.push_back(
|
||||
new OutputCSV(
|
||||
|
|
|
@ -6,7 +6,35 @@ using namespace std ;
|
|||
|
||||
|
||||
|
||||
/* *** Other exceptions *** */
|
||||
/* *** Miscellaneous exceptions *** */
|
||||
|
||||
|
||||
element_not_found::
|
||||
element_not_found(const string &_explanation) throw():
|
||||
posexcept("Element not found in collection: " + _explanation) {}
|
||||
|
||||
|
||||
|
||||
/* *** Configuration *** */
|
||||
|
||||
|
||||
missing_configuration::
|
||||
missing_configuration(const string &_explanation) throw():
|
||||
posexcept(_explanation) {}
|
||||
|
||||
|
||||
bad_configuration::
|
||||
bad_configuration(const string &_explanation) throw():
|
||||
posexcept(_explanation) {}
|
||||
|
||||
|
||||
|
||||
/* *** Input *** */
|
||||
|
||||
|
||||
malformed_topology::
|
||||
malformed_topology(const string &_explanation) throw():
|
||||
posexcept("Error reading the topology: " + _explanation) {}
|
||||
|
||||
|
||||
bad_direction::bad_direction(const char direction) throw()
|
||||
|
@ -18,60 +46,15 @@ bad_direction::bad_direction(const char direction) throw()
|
|||
}
|
||||
|
||||
|
||||
element_not_found::
|
||||
element_not_found(const string &_explanation) throw():
|
||||
posexcept("Element not found in collection:" + _explanation) {}
|
||||
|
||||
|
||||
|
||||
/* *** Data input *** */
|
||||
|
||||
|
||||
topology_input_medium_type_unknown::
|
||||
topology_input_medium_type_unknown(const string &medium_name) throw():
|
||||
posexcept("The specified topology input medium « "+ medium_name +
|
||||
" » is unknown!") {}
|
||||
|
||||
|
||||
no_topology_input_csv_file::
|
||||
no_topology_input_csv_file(const string &type) throw():
|
||||
posexcept(
|
||||
"No topology input CSV file specified in the configuration for "
|
||||
+ type + "!") {}
|
||||
|
||||
|
||||
malformed_topology::
|
||||
malformed_topology(const string &_explanation) throw():
|
||||
posexcept("Error reading the topology:" + _explanation) {}
|
||||
|
||||
|
||||
|
||||
/* *** Input *** */
|
||||
|
||||
|
||||
/**
|
||||
* @param medium_name The medium that is unknown
|
||||
*/
|
||||
input_medium_type_unknown::
|
||||
input_medium_type_unknown(const string &medium_name) throw():
|
||||
posexcept("The specified input medium « "+ medium_name +
|
||||
" » is unknown!") {}
|
||||
|
||||
|
||||
no_input_medium::no_input_medium() throw():
|
||||
posexcept("No input medium specified in configuration!") {}
|
||||
|
||||
|
||||
null_input_medium::null_input_medium() throw():
|
||||
posexcept("The input medium is not initialised!") {}
|
||||
|
||||
|
||||
no_input_csv_file::no_input_csv_file() throw():
|
||||
posexcept("No input CSV file specified in the configuration!") {}
|
||||
|
||||
|
||||
no_log_csv_file::no_log_csv_file() throw():
|
||||
posexcept("No log CSV file specified in the configuration!") {}
|
||||
/* *** Files *** */
|
||||
|
||||
|
||||
error_opening_input_file::
|
||||
|
@ -79,40 +62,6 @@ error_opening_input_file(const string &file_name) throw():
|
|||
posexcept("Error opening input file « " + file_name + " »!") {}
|
||||
|
||||
|
||||
|
||||
/* *** Output *** */
|
||||
|
||||
|
||||
/**
|
||||
* @param medium_name The medium that is unknown
|
||||
*/
|
||||
output_medium_type_unknown::
|
||||
output_medium_type_unknown(const string &medium_name) throw():
|
||||
posexcept("The specified output medium « "+ medium_name +
|
||||
" » is unknown!") {}
|
||||
|
||||
|
||||
no_output_csv_file::no_output_csv_file() throw():
|
||||
posexcept("No output CSV file specified in the configuration!") {}
|
||||
|
||||
|
||||
error_opening_output_file::
|
||||
error_opening_output_file(const string &file_name) throw():
|
||||
posexcept("Error opening output file « " + file_name + " »!") {}
|
||||
|
||||
|
||||
|
||||
/* *** Algorithms *** */
|
||||
|
||||
|
||||
no_positioning_algorithm::no_positioning_algorithm() throw():
|
||||
posexcept("No positioning algorithm specified in configuration!") {}
|
||||
|
||||
|
||||
/**
|
||||
* @param algo_name The algo that is unknown
|
||||
*/
|
||||
positioning_algorithm_unknown::
|
||||
positioning_algorithm_unknown(const string &algo_name) throw():
|
||||
posexcept("The specified positioning_algorithm « "+ algo_name +
|
||||
" » is unknown!") {}
|
||||
|
|
|
@ -26,14 +26,7 @@ public:
|
|||
|
||||
|
||||
|
||||
/* *** Other exceptions *** */
|
||||
|
||||
|
||||
class bad_direction: public posexcept
|
||||
{
|
||||
public:
|
||||
bad_direction(const char direction) throw() ;
|
||||
} ;
|
||||
/* *** Miscellaneous exceptions *** */
|
||||
|
||||
|
||||
class element_not_found: public posexcept
|
||||
|
@ -44,24 +37,27 @@ public:
|
|||
|
||||
|
||||
|
||||
/* *** Data input *** */
|
||||
/* *** Configuration *** */
|
||||
|
||||
|
||||
class topology_input_medium_type_unknown: public posexcept
|
||||
class missing_configuration: public posexcept
|
||||
{
|
||||
public:
|
||||
topology_input_medium_type_unknown(
|
||||
const std::string &medium_name) throw() ;
|
||||
missing_configuration(const std::string &_explanation) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
class no_topology_input_csv_file: public posexcept
|
||||
class bad_configuration: public posexcept
|
||||
{
|
||||
public:
|
||||
no_topology_input_csv_file(const std::string &type) throw() ;
|
||||
bad_configuration(const std::string &_explanation) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
/* *** Input *** */
|
||||
|
||||
|
||||
class malformed_topology: public posexcept
|
||||
{
|
||||
public:
|
||||
|
@ -69,21 +65,10 @@ public:
|
|||
} ;
|
||||
|
||||
|
||||
|
||||
/* *** Input *** */
|
||||
|
||||
|
||||
class input_medium_type_unknown: public posexcept
|
||||
class bad_direction: public posexcept
|
||||
{
|
||||
public:
|
||||
input_medium_type_unknown(const std::string &medium_name) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
class no_input_medium: public posexcept
|
||||
{
|
||||
public:
|
||||
no_input_medium(void) throw() ;
|
||||
bad_direction(const char direction) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
|
@ -94,18 +79,8 @@ public:
|
|||
} ;
|
||||
|
||||
|
||||
class no_input_csv_file: public posexcept
|
||||
{
|
||||
public:
|
||||
no_input_csv_file(void) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
class no_log_csv_file: public posexcept
|
||||
{
|
||||
public:
|
||||
no_log_csv_file(void) throw() ;
|
||||
} ;
|
||||
/* *** Files *** */
|
||||
|
||||
|
||||
class error_opening_input_file: public posexcept
|
||||
|
@ -115,24 +90,6 @@ public:
|
|||
} ;
|
||||
|
||||
|
||||
|
||||
/* *** Output *** */
|
||||
|
||||
|
||||
class output_medium_type_unknown: public posexcept
|
||||
{
|
||||
public:
|
||||
output_medium_type_unknown(const std::string &medium_name) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
class no_output_csv_file: public posexcept
|
||||
{
|
||||
public:
|
||||
no_output_csv_file(void) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
class error_opening_output_file: public posexcept
|
||||
{
|
||||
public:
|
||||
|
@ -141,22 +98,4 @@ public:
|
|||
|
||||
|
||||
|
||||
/* *** Algorithms *** */
|
||||
|
||||
|
||||
class no_positioning_algorithm: public posexcept
|
||||
{
|
||||
public:
|
||||
no_positioning_algorithm(void) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
class positioning_algorithm_unknown: public posexcept
|
||||
{
|
||||
public:
|
||||
positioning_algorithm_unknown(const std::string &algo_name) throw() ;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
#endif // _OWLPS_POSITIONING_POSEXCEPT_HH_
|
||||
|
|
|
@ -34,7 +34,8 @@ Positioning::~Positioning()
|
|||
void Positioning::initialise_algorithms()
|
||||
{
|
||||
if (! Configuration::is_configured("positioning.algorithm"))
|
||||
throw no_positioning_algorithm() ;
|
||||
throw missing_configuration(
|
||||
"No positioning algorithm specified in configuration!") ;
|
||||
|
||||
const vector<string> &algo_names =
|
||||
Configuration::string_vector_value("positioning.algorithm") ;
|
||||
|
@ -49,7 +50,9 @@ void Positioning::initialise_algorithms()
|
|||
algorithms.push_back(new InterlinkNetworks) ;
|
||||
|
||||
else
|
||||
throw positioning_algorithm_unknown(*i) ;
|
||||
throw bad_configuration(
|
||||
"The specified positioning_algorithm « "+ *i +
|
||||
" » is unknown!") ;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ public:
|
|||
void test_constructor(void)
|
||||
{
|
||||
// TODO: test with a mock Configuration?
|
||||
TS_ASSERT_THROWS(Input input1, no_input_medium) ;
|
||||
TS_ASSERT_THROWS(Input input1, missing_configuration) ;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
|
Loading…
Reference in New Issue