From 543156e9d4d738442b34abe38bcd6d55f4b45fae Mon Sep 17 00:00:00 2001 From: Andrew Matsukov Date: Fri, 4 Oct 2024 15:17:48 +0200 Subject: [PATCH] CSC-6035 Fix AttributeError in Office365ClientError --- office365_api/v2/exceptions.py | 1 + office365_api/v2/services.py | 2 +- setup.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/office365_api/v2/exceptions.py b/office365_api/v2/exceptions.py index c02989e..93c1486 100644 --- a/office365_api/v2/exceptions.py +++ b/office365_api/v2/exceptions.py @@ -6,6 +6,7 @@ class Office365ClientError(Exception): def __init__(self, status_code, data): self.status_code = status_code + data = data or {} self.error_code = data.get('error', {}).get('code', '') self.error_message = data.get('error', {}).get('message', '') super(Office365ClientError, self).__init__('{}: {}: {}'.format( diff --git a/office365_api/v2/services.py b/office365_api/v2/services.py index 4329b9c..fd397f4 100644 --- a/office365_api/v2/services.py +++ b/office365_api/v2/services.py @@ -231,7 +231,7 @@ def execute(self): exception = None try: if response['status'] >= 300: - error_data = response['body'] + error_data = response.get('body') raise Office365ClientError(response['status'], error_data) except Office365ClientError as e: exception = e diff --git a/setup.py b/setup.py index 8d16482..6bad3ae 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,8 @@ from setuptools import find_packages, setup setup(name='office365-rest-client', - version='3.3.3', - description='Python api wrapper for Office365 API v3.3.1', + version='3.3.4', + description='Python api wrapper for Office365 API v3.3.4', author='SugarCRM', packages=find_packages(), install_requires=[