fesa-core  7.0.0
fesa::FesaException Class Reference

This class is the based class for all the exceptions in the FESA framework. It contains an error code in order to retrieve the message linked to the error. This error code has to be in the messages.cfg file The class also admits parameters to be replaced in the message in the format $1,$2 ... More...

#include <FesaException.h>

Inherits exception.

Inherited by fesa::FesaBadConfigException, fesa::FesaBadParameterException, fesa::FesaFileException, fesa::FesaInvalidResourceException, fesa::FesaIOException, and fesa::FesaTypeMismatchException.

Public Member Functions

 FesaException ()
 constructor used in the derive classes since we can't use the one with variable parameters
 
 FesaException (const std::string &file, int32_t lineNumber, const char *errorMessage, const std::string &arg1=UNDEFINED_EXCEPTION_ARGUMENT, const std::string &arg2=UNDEFINED_EXCEPTION_ARGUMENT, const std::string &arg3=UNDEFINED_EXCEPTION_ARGUMENT, const std::string &arg4=UNDEFINED_EXCEPTION_ARGUMENT, const std::string &arg5=UNDEFINED_EXCEPTION_ARGUMENT, const std::string &arg6=UNDEFINED_EXCEPTION_ARGUMENT)
 Constructor. More...
 
 FesaException (const std::string &file, int32_t lineNumber, const std::string &message)
 Constructor which can be used without Exception-File. More...
 
 FesaException (const std::string &message, const std::string &file, int32_t lineNumber, const std::string &errorCode, const std::string &errorCategory)
 Constructor which can be used without Exception-File class-developers may inherit from FesaException, and use this constructor to build their message. More...
 
const char * what () const throw ()
 
const std::string & getMessage () const
 This method returns the message linked to the error code of the exception.
 
const std::string & getErrorCode () const
 This method returns the the error code of the exception.
 
const std::string & getErrorCategory () const
 This method returns the the error category of the exception.
 
const std::string & getFileName () const
 get the file in which the exception occurred
 
int32_t getLineNumber () const
 line number in which the exception occurred
 
long getErrorCodeAsLong () const
 This method returns the the error code of the exception as long. More...
 

Static Public Member Functions

static void loadMessages (const std::string &messagesFileName, const std::string &labMessagesFileName)
 This method loads all the messages. It should be called before instatiating exceptions, or only error codes will appear in exceptions messages. Not thread-safe. More...
 
static void loadMessagesFile (const std::string &file)
 This method loads all the messages from the given file. Not thread-safe. More...
 
static void loadMessages (std::istream &input)
 This method loads all the messages from the given stream. Not thread-safe. More...
 

Protected Member Functions

void buildMessage (const std::vector< const std::string * > &arguments)
 

Protected Attributes

std::string message_
 message to return
 
std::string errorCode_
 Some code in order to allow automated identification of the error.
 
std::string errorCategory_
 The project/category to which this error belongs.
 
std::string file_
 file, where the error comes from
 
int32_t lineNumber_
 line number, where the error was thrown
 

Static Protected Attributes

static std::map< std::string,
std::string > 
messages_
 <ErrorCode, Message> This attribute contains the relation between the exception code and the message
 

Detailed Description

This class is the based class for all the exceptions in the FESA framework. It contains an error code in order to retrieve the message linked to the error. This error code has to be in the messages.cfg file The class also admits parameters to be replaced in the message in the format $1,$2 ...

Constructor & Destructor Documentation

fesa::FesaException::FesaException ( const std::string &  file,
int32_t  lineNumber,
const char *  errorMessage,
const std::string &  arg1 = UNDEFINED_EXCEPTION_ARGUMENT,
const std::string &  arg2 = UNDEFINED_EXCEPTION_ARGUMENT,
const std::string &  arg3 = UNDEFINED_EXCEPTION_ARGUMENT,
const std::string &  arg4 = UNDEFINED_EXCEPTION_ARGUMENT,
const std::string &  arg5 = UNDEFINED_EXCEPTION_ARGUMENT,
const std::string &  arg6 = UNDEFINED_EXCEPTION_ARGUMENT 
)

Constructor.

Parameters
errorCode
filein which the exception occurred
linein which the exception occurred
errorMessageto be shown or code associated with it
arg1... arguments used to build the exception message
fesa::FesaException::FesaException ( const std::string &  file,
int32_t  lineNumber,
const std::string &  message 
)

Constructor which can be used without Exception-File.

Parameters
errorCode
filein which the exception occurred
linein which the exception occurred
messageThe final error-message as std::string
fesa::FesaException::FesaException ( const std::string &  message,
const std::string &  file,
int32_t  lineNumber,
const std::string &  errorCode,
const std::string &  errorCategory 
)

Constructor which can be used without Exception-File class-developers may inherit from FesaException, and use this constructor to build their message.

Parameters
messageThe final error-message
filein which the exception occurred
linein which the exception occurred
errorCodeSome code in order to allow automated identification of the error
errorCategoryThe project/category to which this error belongs

Member Function Documentation

void fesa::FesaException::buildMessage ( const std::vector< const std::string * > &  arguments)
protected

Builds the exception message with the given arguments.

Parameters
argumentsvector containing the arguments
long fesa::FesaException::getErrorCodeAsLong ( ) const

This method returns the the error code of the exception as long.

Returns
error code
void fesa::FesaException::loadMessages ( const std::string &  messagesFileName,
const std::string &  labMessagesFileName 
)
static

This method loads all the messages. It should be called before instatiating exceptions, or only error codes will appear in exceptions messages. Not thread-safe.

Parameters
messagesFileNamename of the file containing the generic exception messages
labMessagesFileNamename of the file containing the lab specific exception messages
void fesa::FesaException::loadMessages ( std::istream &  input)
static

This method loads all the messages from the given stream. Not thread-safe.

Parameters
inputthe stream containing the messages
void fesa::FesaException::loadMessagesFile ( const std::string &  file)
static

This method loads all the messages from the given file. Not thread-safe.

Parameters
filethe file containing the messages
const char * fesa::FesaException::what ( ) const
throw (
)
Returns
a string with the error description

The documentation for this class was generated from the following files: