You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Even if the error message and error code are already accessible, I'd like to have an (easy) access to the reason(s) for the error, which could be more explicit than the two elements I've mentioned.
From what I understand, since the error handler in PyYouTubeException is defined in this way :
The “reason” seems to be accessible via the response attribute, which is how most attributes are retrieved when handling the error.
deferror_handler(self):
""" Error has two big type(but not the error type.): This module's error, Api return error. So This will change two error to one format """ifisinstance(self.response, ErrorMessage):
self.status_code=self.response.status_codeself.message=self.response.messageself.error_type="PyYouTubeException"elifisinstance(self.response, Response):
res_data=self.response.json()
if"error"inres_data:
error=res_data["error"]
ifisinstance(error, dict):
self.status_code=res_data["error"]["code"]
self.message=res_data["error"]["message"]
else:
self.status_code=self.response.status_codeself.message=errorself.error_type="YouTubeException"
My point
I'm facing this clarity problem with a current project where I'm logging errors when calling the API. The status_code, the error_type or the message don't give enough information about the type of problem I'm experiencing.
I don't particularly want to have to display the entire response attribute either, as I don't want to overload the logs with unhelpful information.
If we can dig into the error details using “response” to retrieve the attributes we already have, I don't see why we can't do it for the reason for the error, which may be more explicit than the error code.
Even though I've got an idea of how to access this information, it would be a real benefit in terms of error understanding if we could access this information directly through PyYouTubeException attributes.
The text was updated successfully, but these errors were encountered:
The issue
Even if the error message and error code are already accessible, I'd like to have an (easy) access to the reason(s) for the error, which could be more explicit than the two elements I've mentioned.
From what I understand, since the error handler in PyYouTubeException is defined in this way :
The “reason” seems to be accessible via the
response
attribute, which is how most attributes are retrieved when handling the error.My point
I'm facing this clarity problem with a current project where I'm logging errors when calling the API. The
status_code
, theerror_type
or themessage
don't give enough information about the type of problem I'm experiencing.message
attribute in logs instead oferror_type
and the result is not really satisfying; ending up with the message "The operation was aborted.", not giving much information about what actually went wrong.response
attribute either, as I don't want to overload the logs with unhelpful information.If we can dig into the error details using “response” to retrieve the attributes we already have, I don't see why we can't do it for the reason for the error, which may be more explicit than the error code.
Even though I've got an idea of how to access this information, it would be a real benefit in terms of error understanding if we could access this information directly through PyYouTubeException attributes.
The text was updated successfully, but these errors were encountered: