[Positioning] Simplify exceptions in posexcept
This commit is contained in:
parent
8e6883cfc9
commit
675d2d7213
|
@ -9,31 +9,18 @@ using namespace std ;
|
||||||
/* *** Other exceptions *** */
|
/* *** Other exceptions *** */
|
||||||
|
|
||||||
|
|
||||||
bad_direction::bad_direction(const char _direction) throw()
|
bad_direction::bad_direction(const char direction) throw()
|
||||||
{
|
|
||||||
direction = _direction ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* bad_direction::what() const throw()
|
|
||||||
{
|
{
|
||||||
ostringstream message ;
|
ostringstream message ;
|
||||||
message << "`" << static_cast<int>(direction)
|
message << "`" << static_cast<int>(direction)
|
||||||
<< "` is not a valid direction value!" ;
|
<< "` is not a valid direction value!" ;
|
||||||
return message.str().c_str() ;
|
explanation = message.str() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
element_not_found::
|
element_not_found::
|
||||||
element_not_found(const string &_explanation) throw():
|
element_not_found(const string &_explanation) throw():
|
||||||
explanation(_explanation) {}
|
posexcept("Element not found in collection:" + _explanation) {}
|
||||||
|
|
||||||
|
|
||||||
const char* element_not_found::what() const throw()
|
|
||||||
{
|
|
||||||
string message = "Element not found in collection: " + explanation ;
|
|
||||||
return message.c_str() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,56 +28,33 @@ const char* element_not_found::what() const throw()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param _medium_name The medium that is unknown
|
* @param medium_name The medium that is unknown
|
||||||
*/
|
*/
|
||||||
input_medium_type_unknown::
|
input_medium_type_unknown::
|
||||||
input_medium_type_unknown(const string &_medium_name) throw():
|
input_medium_type_unknown(const string &medium_name) throw():
|
||||||
medium_name(_medium_name) {}
|
posexcept("The specified input medium « "+ medium_name +
|
||||||
|
" » is unknown!") {}
|
||||||
|
|
||||||
|
|
||||||
const char* input_medium_type_unknown::what() const throw()
|
no_input_medium::no_input_medium() throw():
|
||||||
{
|
posexcept("No input medium specified in configuration!") {}
|
||||||
string message = "The specified input medium « "+ medium_name +
|
|
||||||
" » is unknown!" ;
|
|
||||||
return message.c_str() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* no_input_medium::what() const throw()
|
null_input_medium::null_input_medium() throw():
|
||||||
{
|
posexcept("The input medium is not initialised!") {}
|
||||||
return "No input medium specified in configuration!" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* null_input_medium::what() const throw()
|
no_input_csv_file::no_input_csv_file() throw():
|
||||||
{
|
posexcept("No input CSV file specified in the configuration!") {}
|
||||||
return "The input medium is not initialised!" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* no_input_csv_file::what() const throw()
|
no_log_csv_file::no_log_csv_file() throw():
|
||||||
{
|
posexcept("No log CSV file specified in the configuration!") {}
|
||||||
return "No input CSV file specified in the configuration!" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* no_log_csv_file::what() const throw()
|
|
||||||
{
|
|
||||||
return "No log CSV file specified in the configuration!" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
error_opening_input_file::
|
error_opening_input_file::
|
||||||
error_opening_input_file(const string &_file_name) throw():
|
error_opening_input_file(const string &file_name) throw():
|
||||||
file_name(_file_name) {}
|
posexcept("Error opening input file « " + file_name + " »!") {}
|
||||||
|
|
||||||
|
|
||||||
const char* error_opening_input_file::what() const throw()
|
|
||||||
{
|
|
||||||
string message = "Error opening input file « " +
|
|
||||||
file_name + " »!" ;
|
|
||||||
return message.c_str() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,61 +62,35 @@ const char* error_opening_input_file::what() const throw()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param _medium_name The medium that is unknown
|
* @param medium_name The medium that is unknown
|
||||||
*/
|
*/
|
||||||
output_medium_type_unknown::
|
output_medium_type_unknown::
|
||||||
output_medium_type_unknown(const string &_medium_name) throw():
|
output_medium_type_unknown(const string &medium_name) throw():
|
||||||
medium_name(_medium_name) {}
|
posexcept("The specified output medium « "+ medium_name +
|
||||||
|
" » is unknown!") {}
|
||||||
|
|
||||||
|
|
||||||
const char* output_medium_type_unknown::what() const throw()
|
no_output_csv_file::no_output_csv_file() throw():
|
||||||
{
|
posexcept("No output CSV file specified in the configuration!") {}
|
||||||
string message = "The specified output medium « "+ medium_name +
|
|
||||||
" » is unknown!" ;
|
|
||||||
return message.c_str() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* no_output_csv_file::what() const throw()
|
|
||||||
{
|
|
||||||
return "No input CSV file specified in the configuration!" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
error_opening_output_file::
|
error_opening_output_file::
|
||||||
error_opening_output_file(const string &_file_name) throw():
|
error_opening_output_file(const string &file_name) throw():
|
||||||
file_name(_file_name) {}
|
posexcept("Error opening output file « " + file_name + " »!") {}
|
||||||
|
|
||||||
|
|
||||||
const char* error_opening_output_file::what() const throw()
|
|
||||||
{
|
|
||||||
string message = "Error opening output file « " +
|
|
||||||
file_name + " »!" ;
|
|
||||||
return message.c_str() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* *** Algorithms *** */
|
/* *** Algorithms *** */
|
||||||
|
|
||||||
|
|
||||||
const char* no_positioning_algorithm::what() const throw()
|
no_positioning_algorithm::no_positioning_algorithm() throw():
|
||||||
{
|
posexcept("No positioning algorithm specified in configuration!") {}
|
||||||
return "No positioning algorithm specified in configuration!" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param _algo_name The algo that is unknown
|
* @param algo_name The algo that is unknown
|
||||||
*/
|
*/
|
||||||
positioning_algorithm_unknown::
|
positioning_algorithm_unknown::
|
||||||
positioning_algorithm_unknown(const string &_algo_name) throw():
|
positioning_algorithm_unknown(const string &algo_name) throw():
|
||||||
algo_name(_algo_name) {}
|
posexcept("The specified positioning_algorithm « "+ algo_name +
|
||||||
|
" » is unknown!") {}
|
||||||
|
|
||||||
const char* positioning_algorithm_unknown::what() const throw()
|
|
||||||
{
|
|
||||||
string message = "The specified positioning_algorithm « "+ algo_name +
|
|
||||||
" » is unknown!" ;
|
|
||||||
return message.c_str() ;
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,7 +7,22 @@
|
||||||
|
|
||||||
|
|
||||||
/// Super-class of all exceptions defined in OWLPS-Positioning
|
/// Super-class of all exceptions defined in OWLPS-Positioning
|
||||||
class posexcept: public std::exception {} ;
|
class posexcept: public std::exception
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
std::string explanation ;
|
||||||
|
|
||||||
|
public:
|
||||||
|
posexcept(const std::string &_explanation = "") throw():
|
||||||
|
explanation(_explanation) {}
|
||||||
|
|
||||||
|
~posexcept(void) throw() {}
|
||||||
|
|
||||||
|
const char* what(void) const throw()
|
||||||
|
{
|
||||||
|
return explanation.c_str() ;
|
||||||
|
}
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,24 +31,15 @@ class posexcept: public std::exception {} ;
|
||||||
|
|
||||||
class bad_direction: public posexcept
|
class bad_direction: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
char direction ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bad_direction(const char _direction) throw() ;
|
bad_direction(const char direction) throw() ;
|
||||||
const char* what() const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class element_not_found: public posexcept
|
class element_not_found: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::string explanation ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
element_not_found(const std::string &_explanation) throw() ;
|
element_not_found(const std::string &_explanation) throw() ;
|
||||||
~element_not_found(void) throw() {}
|
|
||||||
const char* what(void) const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,53 +49,43 @@ public:
|
||||||
|
|
||||||
class input_medium_type_unknown: public posexcept
|
class input_medium_type_unknown: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::string medium_name ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
input_medium_type_unknown(const std::string &_medium_name) throw() ;
|
input_medium_type_unknown(const std::string &medium_name) throw() ;
|
||||||
~input_medium_type_unknown(void) throw() {}
|
|
||||||
const char* what(void) const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class no_input_medium: public posexcept
|
class no_input_medium: public posexcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* what() const throw() ;
|
no_input_medium(void) throw() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class null_input_medium: public posexcept
|
class null_input_medium: public posexcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* what() const throw() ;
|
null_input_medium(void) throw() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class no_input_csv_file: public posexcept
|
class no_input_csv_file: public posexcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* what() const throw() ;
|
no_input_csv_file(void) throw() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class no_log_csv_file: public posexcept
|
class no_log_csv_file: public posexcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* what() const throw() ;
|
no_log_csv_file(void) throw() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class error_opening_input_file: public posexcept
|
class error_opening_input_file: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::string file_name ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
error_opening_input_file(const std::string &_file_name) throw() ;
|
error_opening_input_file(const std::string &file_name) throw() ;
|
||||||
~error_opening_input_file(void) throw() {}
|
|
||||||
const char* what(void) const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,32 +95,22 @@ public:
|
||||||
|
|
||||||
class output_medium_type_unknown: public posexcept
|
class output_medium_type_unknown: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::string medium_name ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
output_medium_type_unknown(const std::string &_medium_name) throw() ;
|
output_medium_type_unknown(const std::string &medium_name) throw() ;
|
||||||
~output_medium_type_unknown(void) throw() {}
|
|
||||||
const char* what(void) const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class no_output_csv_file: public posexcept
|
class no_output_csv_file: public posexcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* what() const throw() ;
|
no_output_csv_file(void) throw() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class error_opening_output_file: public posexcept
|
class error_opening_output_file: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::string file_name ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
error_opening_output_file(const std::string &_file_name) throw() ;
|
error_opening_output_file(const std::string &file_name) throw() ;
|
||||||
~error_opening_output_file(void) throw() {}
|
|
||||||
const char* what(void) const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,19 +121,14 @@ public:
|
||||||
class no_positioning_algorithm: public posexcept
|
class no_positioning_algorithm: public posexcept
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* what() const throw() ;
|
no_positioning_algorithm(void) throw() ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
class positioning_algorithm_unknown: public posexcept
|
class positioning_algorithm_unknown: public posexcept
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
std::string algo_name ;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
positioning_algorithm_unknown(const std::string &_algo_name) throw() ;
|
positioning_algorithm_unknown(const std::string &algo_name) throw() ;
|
||||||
~positioning_algorithm_unknown(void) throw() {}
|
|
||||||
const char* what(void) const throw() ;
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue