Skip to content

Forward MatlabInterperterError to the user #118

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

Merged
merged 1 commit into from
Jan 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pymatbridge/matlab_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def matlab(self, line, cell=None, local_ns=None):
else:
e_s = "There was an error running the code:\n %s"%code
result_dict = self.eval(code)
except MatlabInterperterError:
raise
except:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen with this second exception? Should we remove this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about your code to say. I'm guessing that some other kind of exception is raised when a MATLAB session cannot be found and it would be caught here.

However, I agree that it should be removed if possible, it's not great that it may catch and hide other exceptions at this point to. Do you know what exception gets raised when the interpreter can't be found? If there isn't one, maybe one can be added and this problem could be avoided.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that @isbadawi's subsequent commit (944cf22) actually addresses this well. Sorry for the noise.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We came across this before in #79, and we couldn't figure out what exception was meant to go there. It might make sense to just capture all exceptions from zmq (e.g. wrapped in MatlabCommunicationError or something like that) and catch just those here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and we should also wrap OSErrors from subprocess.Popen as well. That's the part that spawns the matlab process.

e_s += "\n-----------------------"
e_s += "\nAre you sure Matlab is started?"
Expand Down