Added support for yet-unknown error codes
This commit is contained in:
parent
2e6516aa32
commit
baee4f4e22
1 changed files with 453 additions and 444 deletions
15
mpv.py
15
mpv.py
|
|
@ -46,11 +46,16 @@ class ErrorCode:
|
||||||
-12: lambda *a: SystemError('Error running mpv command', *a)
|
-12: lambda *a: SystemError('Error running mpv command', *a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def DEFAULT_ERROR_HANDLER(ec, *args):
|
||||||
|
return ValueError(_mpv_error_string(ec).encode('utf-8'), ec, *a)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def raise_for_ec(kls, func, *args):
|
def raise_for_ec(kls, func, *args):
|
||||||
ec = kls.EXCEPTION_DICT[func(*args)]
|
ec = func(*args)
|
||||||
if ec:
|
ex = kls.EXCEPTION_DICT.get(ec , kls.DEFAULT_ERROR_HANDLER)
|
||||||
raise ec(*args)
|
if ex:
|
||||||
|
raise ex(ec, *args)
|
||||||
|
|
||||||
|
|
||||||
class MpvFormat(c_int):
|
class MpvFormat(c_int):
|
||||||
|
|
@ -209,6 +214,10 @@ backend.mpv_event_name.restype = c_char_p
|
||||||
backend.mpv_event_name.argtypes = [c_int]
|
backend.mpv_event_name.argtypes = [c_int]
|
||||||
_mpv_event_name = backend.mpv_event_name
|
_mpv_event_name = backend.mpv_event_name
|
||||||
|
|
||||||
|
backend.mpv_error_string.restype = c_char_p
|
||||||
|
backend.mpv_error_string.argtypes = [c_int]
|
||||||
|
_mpv_error_string = backend.mpv_error_string
|
||||||
|
|
||||||
_handle_func('mpv_request_event', [MpvEventID, c_int])
|
_handle_func('mpv_request_event', [MpvEventID, c_int])
|
||||||
_handle_func('mpv_request_log_messages', [c_char_p])
|
_handle_func('mpv_request_log_messages', [c_char_p])
|
||||||
_handle_func('mpv_wait_event', [c_double], POINTER(MpvEvent))
|
_handle_func('mpv_wait_event', [c_double], POINTER(MpvEvent))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue