VSM C++ SDK
Vehicle Specific Modules SDK
exception.h File Reference

VSM exceptions definition. More...

#include <string>
#include <stdarg.h>
#include <ugcs/vsm/defs.h>

Go to the source code of this file.

Classes

class  ugcs::vsm::Exception
 Base class for all VSM exceptions. More...
 
struct  ugcs::vsm::Exception::Va_list_overload
 Dummy structure to explicitly indicate the constructor overload for va_list type argument. More...
 
struct  ugcs::vsm::Exception::Va_args_overload
 Dummy structure to explicitly indicate the constructor overload for variable arguments (i.e. More...
 
class  ugcs::vsm::Param_exception< Dummy, TParam >
 Exception class with one parameter. More...
 
class  ugcs::vsm::Derived_exception< Base_exception, Dummy >
 Helper class for defining derived exceptions. More...
 
struct  ugcs::vsm::Debug_assert_exception_dummy_struct
 Exception to throw when debugging assertion fires. More...
 
struct  ugcs::vsm::Nullptr_exception_dummy_struct
 Indicates that some object is not longer exists while its service is invoked. More...
 
struct  ugcs::vsm::Invalid_param_exception_dummy_struct
 Indicates that some invalid parameter was passed to SDK API call. More...
 
struct  ugcs::vsm::Invalid_op_exception_dummy_struct
 Indicates that the operation is invalid in current state. More...
 
struct  ugcs::vsm::Internal_error_exception_dummy_struct
 Some unexpected internal error occurred. More...
 
struct  ugcs::vsm::System_exception_dummy_struct
 Exception for system call failure. More...
 

Namespaces

 ugcs
 UGCS root namespace.
 
 ugcs::vsm
 All VSM SDK functionality resides in this namespace.
 

Macros

#define VSM_EXCEPTION(__exc_class, __msg, ...)
 Throw VSM exception instance. More...
 
#define VSM_PARAM_EXCEPTION(__exc_class, __param, __msg, ...)
 Throw VSM exception instance with parameter. More...
 
#define VSM_SYS_EXCEPTION(__msg, ...)
 Throw VSM system exception - i.e. More...
 
#define VSM_DEFINE_EXCEPTION(__exc_class, ...)
 Define custom exception type. More...
 
#define VSM_DEFINE_DERIVED_EXCEPTION(__base_class, __exc_class)
 Define custom derived exception. More...
 

Typedefs

typedef ugcs::vsm::Param_exception< Debug_assert_exception_dummy_struct,> ugcs::vsm::Debug_assert_exception
 
typedef ugcs::vsm::Param_exception< Nullptr_exception_dummy_struct,> ugcs::vsm::Nullptr_exception
 
typedef ugcs::vsm::Param_exception< Invalid_param_exception_dummy_struct,> ugcs::vsm::Invalid_param_exception
 
typedef ugcs::vsm::Param_exception< Invalid_op_exception_dummy_struct,> ugcs::vsm::Invalid_op_exception
 
typedef ugcs::vsm::Param_exception< Internal_error_exception_dummy_struct,> ugcs::vsm::Internal_error_exception
 
typedef ugcs::vsm::Param_exception< System_exception_dummy_struct,> ugcs::vsm::System_exception
 

Detailed Description

VSM exceptions definition.

Macro Definition Documentation

#define VSM_DEFINE_DERIVED_EXCEPTION (   __base_class,
  __exc_class 
)
Value:
\
struct __exc_class ## _dummy_struct {}; \ \
Helper class for defining derived exceptions.
Definition: exception.h:135

Define custom derived exception.

Parameters
__base_classType of base exception class.
__exc_className for new exception type.
#define VSM_DEFINE_EXCEPTION (   __exc_class,
  ... 
)
Value:
struct __exc_class ## _dummy_struct {}; \
Exception class with one parameter.
Definition: exception.h:88

Define custom exception type.

Parameters
__exc_className for new exception type.
...Parameter type can be specified as second argument.
See also
Param_exception
#define VSM_EXCEPTION (   __exc_class,
  __msg,
  ... 
)
Value:
/* Dummy format argument is added to avoid GCC 4.8.1 bug related to printf attribute. */ \
throw __exc_class(__exc_class::Va_args_overload(), "%s" __msg, "", ## __VA_ARGS__)

Throw VSM exception instance.

Parameters
__exc_classException class name.
__msgFormatted description message.
...Message format parameters.
#define VSM_PARAM_EXCEPTION (   __exc_class,
  __param,
  __msg,
  ... 
)
Value:
/* Dummy format argument is added to avoid GCC 4.8.1 bug related to printf attribute. */ \
throw __exc_class(__exc_class::Va_args_overload(), __param, "%s" __msg, "", ## __VA_ARGS__)

Throw VSM exception instance with parameter.

Parameters
__exc_classException class name.
__paramParameter value.
__msgFormatted description message.
...Message format parameters.
#define VSM_SYS_EXCEPTION (   __msg,
  ... 
)
Value:
do { \
std::string sys_msg = ugcs::vsm::Log::Get_system_error(); \
VSM_EXCEPTION(ugcs::vsm::System_exception, __msg ": %s", ## __VA_ARGS__, sys_msg.c_str()); \
} while (false)
static std::string Get_system_error()
Platform-dependent convenience method to get descriptive string for last system error.
Exception class with one parameter.
Definition: exception.h:88
#define VSM_EXCEPTION(__exc_class, __msg,...)
Throw VSM exception instance.
Definition: exception.h:170

Throw VSM system exception - i.e.

the one caused by system call failure. Special handling is required because system error code might be overwritten by exception allocation functions, so it must be taken as soon as possible.

Parameters
__msgDescriptive message of the failure context.
...Message format parameters.