cmakepp_lang/exceptions/exceptions

Defines the public API for CMakePPLang exception handling.

cmakepp_lang/exceptions/exceptions.cpp_catch()

Declares an exception handler function

This command enables users to declare a handler function for specified exception types. Subsequent calls to the cpp_raise command for those exception types will call the handler function declared for that type.

Parameters:

*args – The exception types to declare handlers for.

Returns:

each arg will be set to the mangled name of the declared exception handler for that exception type.

Return type:

desc

Example Usage

cpp_catch(my_exec_type_1 my_exec_type_2)
function("${my_exec_type_1}" message)
   message("In my_exception_handler for exception type: my_exec_type_1")
   message("Exception details: ${message}")
endfunction()
function("${my_exec_type_2}" message)
   message("In my_exception_handler for exception type: my_exec_type_2")
   message("Exception details: ${message}")
endfunction()

Error Checking

If CMakePP is run in debug mode (and only if it is run in debug mode) this function will assert that it was called with one or more desc arguments.

var CMAKEPP_LANG_DEBUG_MODE:

Used to determine if CMakePP is being run in debug mode or not.

vartype CMAKEPP_LANG_DEBUG_MODE:

bool

cmakepp_lang/exceptions/exceptions.cpp_raise(exce_type)

Raises an exception.

This command raises an exception of the specified type. This will call the exception handler for that type if it is declared.

Parameters:
  • exec_type (desc) – The exception type to be raised

  • exec_message (optional desc) – The exception message

Example Usage

cpp_raise(my_exec_type)

An exception message may be optionally added via calling with additonal parameters.

cpp_raise(my_exec_type "My exception message")

Error Checking

If CMakePP is run in debug mode (and only if it is run in debug mode) this function will assert that it was called with at least one argument and that the argument is of type desc.

var CMAKEPP_LANG_DEBUG_MODE:

Used to determine if CMakePP is being run in debug mode or not.

vartype CMAKEPP_LANG_DEBUG_MODE:

bool

cmakepp_lang/exceptions/exceptions.cpp_try()

Note

This is a macro, and so does not introduce a new scope.

Denotes that we are starting a try block.

This function is a no-op that completes the fencing associated with a try block.

Error Checking

None. This function is a no-op and has no errors to check for.

cmakepp_lang/exceptions/exceptions.cpp_end_try_catch()

Ends a try-catch block

This command ends a try-catch block and removes the exception handlers for the specified types.

Parameters:

*args – The exception types to declare handlers for.

Variables:

CMAKEPP_LANG_DEBUG_MODE (bool) – Used to determine if CMakePP is being run in debug mode or not.

Example Usage

cpp_end_try_catch(my_exce_type)

Error Checking

If CMakePP is run in debug mode (and only if it is run in debug mode) this function will assert that it was called with one or more desc arguments.