py::builtins::BaseException::operator =

BaseException& operator = (const BaseException& other); // 1

BaseException& operator = (BaseException&& other);      // 2

Assigns another BaseException object to the object.

Parameters

other: Another instance of BaseException.

Return value

*this.

Example

#include <pypp/builtins.hpp>

int main()
{
    try
    {
        py::BaseException exception;
        exception = py::BaseException("example exception")
        py::raise(exception);
    }
    catch (py::BaseException& exception)
    {
        py::print("exception handled successfully:", exception);
    }
}

Output:

exception handled successfully: example exception