std::exception¶
Most of the time you do not have to worry about C++ exceptions. Rice automatically handles C++ exceptions and converts them to the appropriate Ruby exception.
However, although rare, some C++ APIs define methods that take exception parameters. For example, OpenCV’s API includes:
class AsyncPromise
{
public:
/** Stores exception.
@param[in] exception exception to be raised in AsyncArray */
void setException(const cv::Exception& exception);
};
Thus Rice provides access to creating new C++ exception instances:
exception = Rice::Std::Exception.new
Note currently only supports creating instances of std::exception
and none of its subtypes.
Ruby API¶
The Ruby API for std::exception
is:
Exception#new (see constructor)
Exception#what (see what)