Main Content

mwException

Exception type used by the mwArray API and the C++ interface functions

Description

The mwException class is the basic exception type used by the mwArray API and the C++ interface functions. All errors created during calls to the mwArray API and to generated C++ interface functions are thrown as mwExceptions.

Required Headers

  • mclcppclass.h

  • mclmcrrt.h

Tip

MATLAB® Compiler SDK™ automatically includes these header files in the header file generated for your MATLAB functions.

Constructors

mwException()

Description

Construct new mwException with default error message.

mwException(char* msg)

Description

Create an mwException with a specified error message.

Arguments
char* msgNull terminated character buffer to use as the error message

mwException(mwException& e)

Description

Create a copy of an mwException.

Arguments
mwException& eInitialized mwException instance to copy

mwException(std::exception& e)

Description

Create new mwException from existing std::exception.

Arguments
std::exception& estd::exception to copy

Methods

char* what() const throw()

Description

Return the error message contained in this exception.

Example
try
{
    ...
}
catch (const std::exception& e)
{
    std::cout << e.what() << std::endl;
}

void print_stack_trace()

Description

Print the stack trace to std::cerr.

Operators

mwException& operator=(const mwException& e)

Description

Copy the contents of one exception into a new exception.

Arguments
mwException& eAn initialized mwException instance to copy
Example
try
{
    ...
}
catch (const mwException& e)
{
    mwException e2 = e;
    throw e2;
}

mwException& operator=(const std::exception& e)

Description

Copy the contents of one exception into a new exception.

Arguments
std::exception& estd::exception to copy
Example
try
{
    ...
}
catch (const std::exception& e)
{
    mwException e2 = e;
    throw e2;
}

Version History

Introduced in R2013b