Deepsolver
Classes | Public Types | Public Member Functions | Static Public Member Functions
Deepsolver::ConfigException Class Reference

Indicates an error in configuration data. More...

Inheritance diagram for Deepsolver::ConfigException:
Deepsolver::AbstractException

List of all members.

Classes

struct  Descr

Public Types

enum  {
  UnknownOption, ValueCannotBeEmpty, AddingNotPermitted, InvalidBooleanValue,
  InvalidIntValue, InvalidUIntValue, InvalidUrl, CodeCount
}

Public Member Functions

void accept (ExceptionVisitor &visitor) const
 Calls appropriate visitor method.
 ConfigException (int code, const StringVector &path, const std::string &sectArg, const std::string &line, const std::string &fileName, size_t lineNumber)
 The constructor.
int getCode () const
 Returns the error code.
std::string getFileName () const
 Returns a file name with an invalid line.
std::string getLine () const
 Returns an invalid line value.
size_t getLineNumber () const
 Returns number of a invalid line.
std::string getLocationDesignation () const
 Returns full designation of configuration problem location.
std::string getMessage () const
 Returns a single line error description.
std::string getOptionDesignation () const
 Returns a string designation of a configuration option with an invalid value.
const StringVector & getPath () const
 Returns a configuration option path.
std::string getSectArg () const
 Returns a first-level section argument.
std::string getType () const
 Returns a string with short error type designation.
virtual ~ConfigException ()
 The destructor.

Static Public Member Functions

static std::string getDescr (int code)
 Generates English problem description by the given code.

Detailed Description

This class instance indicates any problem in Deepsolver configuration structures. Be careful, it must be not confused with ConfigFileException, used to notify about configuration file syntax errors.

The objects of ConfigException provide the error code, option path with section argument if needed and error location in configuration file if there is any. Note, some sort of problems are still meaningful even without any reference to location in a configuration file.

See also:
ConfigFileException

Constructor & Destructor Documentation

Deepsolver::ConfigException::ConfigException ( int  code,
const StringVector &  path,
const std::string &  sectArg,
const std::string &  line,
const std::string &  fileName,
size_t  lineNumber 
) [inline]
Parameters:
[in]codeThe error code
[in]pathA value path
[in]sectArgAn argument for first-level section
[in]lineAn invalid line value
[in]fileNameThe name of the config file with the invalid line
[in]lineNumberA number of the invalid line

Member Function Documentation

void Deepsolver::ConfigException::accept ( ExceptionVisitor visitor) const [inline, virtual]

This method performs invocation of corresponding visit() method of the visitor, provided by the reference. You should use it each time, when you want to make particular handling action for various exception types, as it suggested by design pattern "visitor".

Parameters:
[in]visitorThe reference to the visitor

Implements Deepsolver::AbstractException.

int Deepsolver::ConfigException::getCode ( ) const [inline]
Returns:
The error code
static std::string Deepsolver::ConfigException::getDescr ( int  code) [inline, static]
Parameters:
[in]codeThe error code to generate description for
Returns:
The generated English error description
std::string Deepsolver::ConfigException::getFileName ( ) const [inline]
Returns:
A file name with the invalid line
std::string Deepsolver::ConfigException::getLine ( ) const [inline]
Returns:
An invalid line value
size_t Deepsolver::ConfigException::getLineNumber ( ) const [inline]

Use this method to get 1-based number of an invalid line. If this method returns 0 that means the error is not associated with any location in configuration files.

Returns:
A number of the line caused the problem or zero if there is no any
std::string Deepsolver::ConfigException::getLocationDesignation ( ) const [inline]

This method constructs string with unique designation of a place causing configuration problem. This information usually includes file name and line number.

Returns:
A string designation of a configuration problem location
std::string Deepsolver::ConfigException::getMessage ( ) const [virtual]

This method returns a single line string value with error description. Usually it is the value printed to user in the error message. The value should not include error type, since it can be obtained through getType() method.

Returns:
A single line error description

Implements Deepsolver::AbstractException.

std::string Deepsolver::ConfigException::getOptionDesignation ( ) const [inline]
Returns:
A unique configuration option designation
const StringVector& Deepsolver::ConfigException::getPath ( ) const [inline]
Returns:
A configuration option path
std::string Deepsolver::ConfigException::getSectArg ( ) const [inline]
Returns:
A first-level section argument if there is any
std::string Deepsolver::ConfigException::getType ( ) const [inline, virtual]

This method returns a short string with one or two words describing the error type. For example, this method can return values like "system", "back-end" etc. A value returned by this method usually is used for error message construction.

Returns:
A short string with error type designation

Implements Deepsolver::AbstractException.