Skip to content
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

Aio exception problem 73 #75

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.DS_Store
# No PyCharm config files
.idea/
venv/
venv/
__pycache__
3 changes: 2 additions & 1 deletion meraki/aio/rest_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ async def request(self, metadata, method, url, **kwargs):
return None
else:
response = None
message = None
for _ in range(retries):
# Make the HTTP request to the API endpoint
try:
Expand Down Expand Up @@ -154,7 +155,7 @@ async def request(self, metadata, method, url, **kwargs):
self._logger.error(
f"{tag}, {operation} - {status} {reason}, {message}"
)
raise AsyncAPIError(metadata, response, await response.text())
raise AsyncAPIError(metadata, response, message)

async def get(self, metadata, url, params=None):
metadata["method"] = "GET"
Expand Down
10 changes: 4 additions & 6 deletions meraki/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ def __init__(self, metadata, response, message):
self.response = response
self.tag = metadata['tags'][0]
self.operation = metadata['operation']
self.status = self.response.status if self.response is not None and self.response.status else None
self.reason = self.response.reason if self.response is not None and self.response.reason else None
try:
self.message = self.response.json() if self.response is not None and self.response.json() else None
except ValueError:
self.message = self.response.text[:100]
self.status = response.status if response is not None and response.status else None
self.reason = response.reason if response is not None and response.reason else None
self.message = message

super().__init__(
f'{self.tag}, {self.operation} - {self.status} {self.reason}, {self.message}'
)
Expand Down