jbaiter / gphoto2-cffi

Python bindings for libgphoto2 with an idiomatic API
GNU Lesser General Public License v3.0
37 stars 16 forks source link

Other error codes #22

Closed define-private-public closed 7 years ago

define-private-public commented 7 years ago

Hi,

I was working on my project where I need to poll for a live feed using get_preview(), but it's possible that the user may turn off the camera, thus throwing a Ghoto2Error with an error_code of -7. After poking through the libphoto2 source, I found out that there is a second header file that has error codes, and IIRC, a lot of them are missing from errors.py.

The file can be found in libgphoto2_port/gphoto2/gphoto2-port-result.h. Can you add some of these error codes to the library? I can understand if making full blown custom exceptions for them might be a bit, but I'd rather use an error code from the library than have to hard code in -7 in my application.

Thanks, ~Ben

thijstriemstra commented 7 years ago

@define-private-public can you add those and create a pull request? cheers!

jbaiter commented 7 years ago

I added the remaining error codes to the backend. You can now check e.g. against gphoto2cffi.backend.lib.GP_ERROR_IO instead of -7.