Common LiMaL exceptions.
More...
#include "ca-mgm/config.h"
#include <ca-mgm/String.hpp>
#include <string.h>
Go to the source code of this file.
|
#define | CA_MGM_DECLARE_EXCEPTION2(NAME, BASE) |
|
#define | CA_MGM_DECLARE_EXCEPTION(NAME) CA_MGM_DECLARE_EXCEPTION2(NAME, ca_mgm::Exception) |
|
#define | CA_MGM_DEFINE_EXCEPTION2(NAME, BASE) |
|
#define | CA_MGM_DEFINE_EXCEPTION(NAME) CA_MGM_DEFINE_EXCEPTION2(NAME, ca_mgm::Exception) |
|
#define | CA_MGM_THROW(exType, msg) throw exType(__FILE__, __LINE__, (msg)) |
|
#define | CA_MGM_THROW_SUBEX(exType, msg, subex) throw exType(__FILE__, __LINE__, (msg), -1, &(subex)) |
|
#define | CA_MGM_THROW_ERR(exType, msg, err) throw exType(__FILE__, __LINE__, (msg), (err)) |
|
#define | CA_MGM_THROW_ERRNO(exType) CA_MGM_THROW_ERRNO1(exType, errno) |
|
#define | CA_MGM_THROW_ERRNO1(exType, errnum) throw ::ca_mgm::ExceptionDetail::Errno< exType >::simple(__FILE__, __LINE__, (errnum)) |
|
#define | CA_MGM_THROW_ERRNO_MSG(exType, msg) CA_MGM_THROW_ERRNO_MSG1(exType, (msg), errno) |
|
#define | CA_MGM_THROW_ERRNO_MSG1(exType, msg, errnum) |
|
Common LiMaL exceptions.
This header file declares several common exception types.
BloCxx provides several macros helping to throw exceptions:
"Can't do this and that");
const int MY_INVALID_EMAIL_ERROR_NUMBER = 42;
"Argument is not a valid email",
MY_INVALID_EMAIL_ERROR_NUMBER);
str::form(
"Syntax error in line %1", 42).c_str());
try
{
do_something();
}
{
"Bad things happened", subex);
}
See BloCxx documentation for more informations.
Declare a new exception class named <NAME>Exception that derives from Exception This macro is typically used in a header file.
- Parameters
-
NAME | The name of the new class (Exception will be postfixed) |
#define CA_MGM_DECLARE_EXCEPTION2 |
( |
|
NAME, |
|
|
|
BASE |
|
) |
| |
Value:class NAME##Exception : public BASE \
{ \
public: \
NAME##Exception(
const char* file,
int line,
const char* msg,
int errorCode = 0,
const ca_mgm::Exception* otherException = 0); \
virtual ~NAME##Exception() throw(); \
virtual const char* type() const; \
};
Definition: Exception.hpp:64
Declare a new exception class named <NAME>Exception that derives from <BASE>. This macro is typically used in a header file.
- Parameters
-
NAME | The name of the new class (Exception will be postfixed) |
BASE | The base class. |
Define a new exception class named <NAME>Exception that derives from Exception. The new class will use UNKNOWN_SUBCLASS_ID for the subclass id. Use this macro for internal implementation exceptions that don't have an id. This macro is typically used in a cpp file.
- Parameters
-
NAME | The name of the new class (Exception will be postfixed) |
#define CA_MGM_DEFINE_EXCEPTION2 |
( |
|
NAME, |
|
|
|
BASE |
|
) |
| |
Value:NAME##Exception::NAME##Exception(const char* file, int line, const char* msg, int errorCode, const ::ca_mgm::Exception* otherException) \
: BASE(file, line, msg, errorCode, otherException) {} \
NAME##Exception::~NAME##Exception() throw() { } \
const char* NAME##Exception::type() const { return #NAME "Exception"; }\
Define a new exception class named <NAME>Exception that derives from <BASE>. The new class will use UNKNOWN_SUBCLASS_ID for the subclass id. This macro is typically used in a cpp file.
- Parameters
-
NAME | The name of the new class (Exception will be postfixed) |
BASE | The base class. |
#define CA_MGM_THROW |
( |
|
exType, |
|
|
|
msg |
|
) |
| throw exType(__FILE__, __LINE__, (msg)) |
Throw an exception using FILE and LINE. If applicable, CA_MGM_THROW_ERR should be used instead of this macro.
- Parameters
-
exType | The type of the exception |
msg | The exception message. A string that will be copied. |
#define CA_MGM_THROW_ERR |
( |
|
exType, |
|
|
|
msg, |
|
|
|
err |
|
) |
| throw exType(__FILE__, __LINE__, (msg), (err)) |
Throw an exception using FILE and LINE.
- Parameters
-
exType | The type of the exception |
msg | The exception message. A string that will be copied. |
err | The error code. |
Throw an exception using FILE, LINE, errno and strerror(errno)
- Parameters
-
exType | The type of the exception; ctor must take file, line, message, and error code. |
Throw an exception using FILE, LINE, errnum and strerror(errnum)
- Parameters
-
exType | The type of the exception; ctor must take file, line, message, and error code. |
errnum | The errno value. |
Throw an exception using FILE, LINE, errno and strerror(errno)
- Parameters
-
exType | The type of the exception; ctor must take file, line, message, and error code. |
msg | The exception message to use. |
#define CA_MGM_THROW_ERRNO_MSG1 |
( |
|
exType, |
|
|
|
msg, |
|
|
|
errnum |
|
) |
| |
Value:throw ::ca_mgm::ExceptionDetail::Errno< exType >:: \
format(__FILE__, __LINE__, (msg), (errnum))
Throw an exception using FILE, LINE, errnum and strerror(errnum)
- Parameters
-
exType | The type of the exception; ctor must take file, line, message, and error code. |
msg | The exception message to use. |
errnum | The errno value. |
#define CA_MGM_THROW_SUBEX |
( |
|
exType, |
|
|
|
msg, |
|
|
|
subex |
|
) |
| throw exType(__FILE__, __LINE__, (msg), -1, &(subex)) |
Throw an exception using FILE and LINE.
- Parameters
-
exType | The type of the exception |
msg | The exception message. A string that will be copied. |
subex | A sub-exception. A pointer to it will be passed to the exception constructor, which should clone() it. |