Changed the configure_loggers_from_file() function so that it throws a

specific exception rather than dlib::error upon encountering a problem.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403745
This commit is contained in:
Davis King 2010-07-17 13:33:29 +00:00
parent 9d09a8db3d
commit fcf61e2f42
2 changed files with 13 additions and 3 deletions

View File

@ -146,7 +146,7 @@ namespace dlib
ifstream fin(file_name.c_str());
if (!fin)
throw error("logger_config: unable to open config file " + file_name);
throw logger_config_file_error("logger_config: unable to open config file " + file_name);
cr_type main_cr;
@ -181,7 +181,7 @@ namespace dlib
if (one == "file" && three.size() == 0)
set_all_logging_output_streams(get_file_stream(two));
else
throw error("logger_config: invalid argument to output option: " + output);
throw logger_config_file_error("logger_config: invalid argument to output option: " + output);
}
} // if (cr.is_key_defined("output"))

View File

@ -12,6 +12,16 @@
namespace dlib
{
class logger_config_file_error : public error
{
/*!
WHAT THIS OBJECT REPRESENTS
This is the exception class used by the configure_loggers_from_file()
function defined below.
!*/
public:
logger_config_file_error(const std::string& s):error(s){}
};
void configure_loggers_from_file (
const std::string& file_name
@ -20,7 +30,7 @@ namespace dlib
ensures
- configures the loggers with the contents of the file_name file
throws
- dlib::error
- dlib::logger_config_file_error
this exception is thrown if there is a problem reading the config file
!*/