I have a problem with eclipse and my python decorator. I use a decorator to manage communication error automatically. When I use the decorator, by default, the decorator will get the error of the decorated function, and if it is not OK, raise an exception.
def error_handling_decor_2(function):
@wraps(function)
def wrapper(*args, **kwargs):
catch_error = kwargs.get('catch_error', True)
kwargs.pop('catch_error', None)
(ret_val, error_val) = function(*args, **kwargs)
if catch_error:
if error_val == 'OK':
return ret_val
else:
raise Exception('Problem')
else:
# return without any processing
return ret_val, error_val
return wrapper
So if I want the decorated function to return a tuple with (ret_val, error)
, I have to pass as parameter: catch_error=False
.
Everything is working correctly, the only problem is that eclipse show an error on the editor: Passing unexpected keyword argument 'catch_error' in function call
.
That is right, the method call does not have argument catch_error
but the decorator does handle it.
Does anyone have an idea to avoid seeing this error?