Skip to content
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

Issue with error handling in setSLMImage #76

Closed
ianhi opened this issue Dec 7, 2022 · 3 comments · Fixed by #87
Closed

Issue with error handling in setSLMImage #76

ianhi opened this issue Dec 7, 2022 · 3 comments · Fixed by #87

Comments

@ianhi
Copy link
Contributor

ianhi commented Dec 7, 2022

Not sure if this belongs here in or in pymmcore but the following code crashes python:

from pymmcore import CMMCore
from pymmcore_plus import CMMCorePlus as CMMCore
core = CMMCore()
try:
    core.setSLMImage("nothing-loaded", "\x01"*512*512)
except Exception as e:
    print(repr(e))

print("did we get here?")

giving the following output:

terminate called after throwing an instance of 'CMMError'
  what():  No device with label "nothing-loaded"
Aborted (core dumped)

While I certainly expect an error to be thrown, I don't expect this cause python to crash, contrast with the same situation for snapImage:

from pymmcore import CMMCore
from pymmcore_plus import CMMCorePlus as CMMCore
core = CMMCore()
try:
    core.snapImage()
except Exception as e:
    print(repr(e))
    pass

print("did we get here?")

which gives:

RuntimeError('Camera not loaded or initialized.')
did we get here?
@marktsuchida marktsuchida transferred this issue from micro-manager/mmCoreAndDevices Dec 7, 2022
@marktsuchida
Copy link
Member

Thanks. This looks like a pymmcore problem (the hand-written wrapper is not handling exceptions), so transferred.

@marktsuchida
Copy link
Member

Although this is indeed a pymmcore, not MMCore, problem, it turns out that MMCoreJ has the exact same problem (not handling exceptions). So I filed micro-manager/mmCoreAndDevices#309 for that.

@jdlamstein
Copy link

Thanks for working on this guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants