diff options
| author | morefigs <morefigs@gmail.com> | 2013-12-22 18:50:22 -0800 |
|---|---|---|
| committer | morefigs <morefigs@gmail.com> | 2013-12-22 18:50:22 -0800 |
| commit | 74673966eddf436898d558b60f7827cb4b7a95c2 (patch) | |
| tree | e36f3e3653b49fd8495e7e89d24569963e2b14fb /vimbaexception.py | |
| parent | 6aa2ed6190632236b2d1b6383f336900a86c5f7c (diff) | |
| download | pymba-74673966eddf436898d558b60f7827cb4b7a95c2.tar.gz pymba-74673966eddf436898d558b60f7827cb4b7a95c2.zip | |
Create vimbaexception.py
Diffstat (limited to 'vimbaexception.py')
| -rw-r--r-- | vimbaexception.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vimbaexception.py b/vimbaexception.py new file mode 100644 index 0000000..676b38d --- /dev/null +++ b/vimbaexception.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +import exceptions + +class VimbaException(Exception): + """ + An exception for the AVT Vimba API. It contains a message + property which is a string indicating what went wrong. + + :param errorCode: Error code to be used to look up error message. + """ + + @property + def message(self): + return self._errorCodes[self.errorCode] + + @property + def errorCode(self): + return self._errorCode + + _errorCodes = { # Vimba C API specific errors + 0: 'No error.', + -1: 'Unexpected fault in VimbaC or driver.', + -2: 'VmbStartup() was not called before the current command.', + -3: 'The designated instance (camera, feature etc.) cannot be found.', + -4: 'The given handle is not valid, ensure device open.', + -5: 'Device was not opened for usage.', + -6: 'Operation is invalid with the current access mode.', + -7: 'One of the parameters was invalid (usually an illegal pointer).', + -8: 'The given struct size is not valid for this version of the API.', + -9: 'More data was returned in a string/list than space was provided.', + -10: 'The feature type for this access function was wrong.', + -11: 'The value was not valid; either out of bounds or not an increment of the minimum.', + -12: 'Timeout during wait.', + -13: 'Other error.', + -14: 'Resources not available (e.g. memory).', + -15: 'Call is invalid in the current context (e.g. callback).', + -16: 'No transport layers were found.', + -17: 'API feature is not implemented.', + -18: 'API feature is not supported.', + -19: 'A multiple registers read or write was partially completed.', + + # Custom errors + -50: 'Could not find the specified camera.', + -51: 'Not enough memory to assign frame buffer.', + -52: 'Invalid input.', + -53: 'Could not find the specified feature.', + + # Miscellaneous errors + -1000: 'Oops, unknown internal error code!', + -1001: 'Oops, this VimbaFeature function is not yet implemented!'} + + def __init__(self, errorCode): + # if error code does not match expected codes then assign invalid code + if errorCode in self._errorCodes: + self._errorCode = errorCode + else: + self._errorCode = -1000 + + + + + |
