You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integrate the latest version of libmexclass (commit 77f3d72) to support error-handling.
Here's an overview of the changes:
Added a simple class called libmexclass::error::Error which has two std::string member properties: id and message.
Added a new field named error to libmexclass::proxy::method::Context. error is a std::optional<libmexclass::error::Error>. Proxy class methods can set this field if an error occurred.
The gateway MEX function checks if error is set. If so, it throws a MATLAB facing error using the id and message stored in error.
To support throwing errors at construction, proxy classes are now required to define a static make function with the following signature: libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments); The output argument libmexclass::proxy::MakeResult is a typedef to std::variant<std::shared_ptr<libmexclass::proxy::Proxy>, libmexclass::error::Error>.
Component(s)
MATLAB
The text was updated successfully, but these errors were encountered:
…t error-handling (#35918)
### Rationale for this change
This change integrates the latest version of `mathworks/libmexclass` into the MATLAB interface which enables throwing MATLAB errors.
The [77f3d72](mathworks/libmexclass@77f3d72) in `libmexclass` introduced the following changes:
1. Added a new class called `libmexclass::error::Error`.
2. Added a new field called `error` on the `libmexclass::proxy::method::Context` which is a `std::optional<libmexclass::proxy::Error>`. By default, this is a `std::nullopt`. To make MATLAB throw an error, set this optional.
3. To support throwing errors at construction, `libmexclass` now requires all `Proxy` subclasses to define a static `make` method: `static libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments)`. This workflow is similar to using an `arrow::Result<T>`object.
Examples of throwing errors in MATLAB can be found on lines [45](https://github.com/mathworks/libmexclass/blob/77f3d72c22a9ddab7b54ba325d757c3e82e57987/example/proxy/Car.cpp#L45) and [94](https://github.com/mathworks/libmexclass/blob/77f3d72c22a9ddab7b54ba325d757c3e82e57987/example/proxy/Car.cpp#L94) in [libmexclass/example/proxy/Car.cpp](https://github.com/mathworks/libmexclass/blob/main/example/proxy/Car.cpp)
### What changes are included in this PR?
1. Pulled in the latest version of `libmexclass`: [77f3d72](mathworks/libmexclass@77f3d72).
2. Added `static libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments)` to `arrow::matlab::proxy::NumericArray<Type>`.
3. Throw an error when trying to create an unknown proxy class.
### Are these changes tested?
1. Added a new test class called `tGateway.m` that verifies `libmexclass.proxy.gateway("Create", ...)` errors if given the name of an unknown proxy class.
### Are there any user-facing changes?
No.
* Closes: #35914
Lead-authored-by: Sarah Gilmore <sgilmore@mathworks.com>
Co-authored-by: sgilmore10 <74676073+sgilmore10@users.noreply.github.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Co-authored-by: Kevin Gurney <kgurney@mathworks.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Describe the enhancement requested
Integrate the latest version of
libmexclass
(commit 77f3d72) to support error-handling.Here's an overview of the changes:
libmexclass::error::Error
which has twostd::string
member properties:id
andmessage
.error
tolibmexclass::proxy::method::Context
.error
is astd::optional<libmexclass::error::Error>
. Proxy class methods can set this field if an error occurred.error
is set. If so, it throws a MATLAB facing error using theid
andmessage
stored inerror
.libmexclass::proxy::MakeResult make(const libmexclass::proxy::FunctionArguments& constructor_arguments);
The output argumentlibmexclass::proxy::MakeResult
is a typedef tostd::variant<std::shared_ptr<libmexclass::proxy::Proxy>, libmexclass::error::Error>
.Component(s)
MATLAB
The text was updated successfully, but these errors were encountered: