-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error-handling from Engine #14
Comments
I think #15 may provide a solution; we could ship a function function result = tryToEither(fun, varargin)
result = struct('left', struct('message', 'tryToEither: try nor catch succeeded'));
try
funResult = fun(varargin{:});
result = struct('right', statementString);
catch ex
result = struct('left', ex);
end
end Of course we may need a similar function shipped to create a function handle, haven't tested that yet (or seen any evidence of function handle support in the MATLAB Engine API). |
Also, regarding Haskell-exceptions and errors, I'm guessing that foreign calls can't initiate an exception (at least not one that can be handled), unless we implement a wrapper as described above. One possible caveat might be: if the FFI call somehow called back into Haskell, and an exception was thrown in the Haskell code at that point. Chessai says: i believe that the thread running the c code will just inherit whatever exception is thrown. you can catch them from haskell using the handlers in posix (which is not supported on windows). Minimalist segfaulting haskell program: https://gist.github.com/chessai/a9ae3d56b8f64ea6dce6065808fa3726 |
Possibly related: #10
Currently, some errors, like those causes by improper (or buggy) use of
clearVar
, cause output to happen in stderr (I think). We could detect this in MATLAB with try-catch and return MATLAB incantation ofEither
. See here for a discussion on the issue of using try/catch, however.So, other avenues of attack may need to be considered as well.
The text was updated successfully, but these errors were encountered: