-
Notifications
You must be signed in to change notification settings - Fork 15
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
Identify REST exception origin #751
Comments
Well, originally the intention behind introducing the |
In case of
But there is another requirement from our PO (product owner) -
Still there will be problems importing those exceptions from our OT's, but I don't think that use properties is better idea:
|
Well, the Pythonic way would be to define service-specific exceptions, and handle them using try:
aubo.something_that_calls_scene_service_inside()
except AuboSpecificException:
pass
except AuboException:
pass
except SceneServiceException:
pass
except RestException:
pass
except Arcor2Exception:
pass
except Exception:
pass The identifier is the exception type itself. Everything else seems to me as unnecessarily complicated and against Python's nature (e.g. single except and then some conditions). I'm not sure what will be the advantage of having the from arcor2.data.common import WebAbiError
class AuboException(WebAbiError):
origin = "aubo" ...or this: class KinaliBaseException(WebApiError):
@property
def origin():
return self.__class__.__name__[:-9]
class AuboException(KinaliBaseException):
pass ...moreover, there is already the |
Thanks for your advices, I've reviewed the issue and our requirements and it seems like we can solve it on our side by using There still is an problem with such approach, which blocks solving current issue. This is related to |
Yes, I agree. Changing the ancestor of In the meantime, you may use something like this to get the "parent" try:
scene_client.whatever()
except SceneServiceException as e:
if isinstance(e.__context__, WebApiError):
pass |
Do you mean |
And by the way, wouldn't it be more logical to base |
Well, using Yes, it make sense to derive |
We are currently dealing with issue - when calling
scene_service.start()
, this call might take too long (longer then defined 20s. rest timeout) and then will consequently fail withRestException
as timeout will happen. We would like to add an opportunity to easily identify the origin of the error for eachrest.call
call (scene service client in this case).Proposed solution
When
rest.call
raise any exception it get's converted byarcor2.exceptions.helpers.handle
toSceneServiceException
. However, not all service clients has such conversion implemented. Moreover, this logic must be changed after new API convention is implemented as it hidesWebApiError
properties (convertWebApiError
to string to raise required exception type).It would be enough to implement a function that will accept service unique exception (for scene service it would be
SceneServiceException
) and will return wrappedrest.call
function. Wrapper will catch onlyRestException
exceptions and raise desired type from it (just likearcor2.exceptions.helpers.handle
does).Each client that will want to mark rest error origin will request wrapped
rest.call
and use it as usually.The text was updated successfully, but these errors were encountered: