Skip to content

Commit fc357ed

Browse files
entry functions added
1 parent 7b57e4d commit fc357ed

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

contentstack/errors.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def error(self):
6767

6868
@property
6969
def error_info(self) -> dict:
70-
7170
"""
7271
:return: dict, error information
7372
"""
@@ -100,12 +99,12 @@ def error_info(self) -> dict:
10099
429: "The number of requests exceeds the allowed limit for the given time period.",
101100
500: "The server is malfunctioning and is not specific on what the problem is.",
102101
502: "A server received an invalid response from another server.",
103-
504: "A server did not receive a timely response from another server that it was accessing while attempting to load the web page or fill another request by the browser."
102+
504: "A server did not receive a timely response from another server that it was accessing while attempting "
103+
"to load the web page or fill another request by the browser. "
104104
}
105105

106106
@staticmethod
107107
def logging_config(level):
108-
109108
print('level ' + level)
110109

111110

@@ -117,5 +116,9 @@ class StackException(Exception):
117116
pass
118117

119118

119+
class ContentstackError(Exception):
120+
pass
121+
122+
120123
class NotSupportedException(Exception):
121124
pass

contentstack/http_connection.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_result(self, url: str, query: dict, headers: dict) -> tuple:
1616
from urllib import parse
1717
from requests import Response
1818
from contentstack.stack import SyncResult
19-
from contentstack import Error
19+
from contentstack.errors import ContentstackError
2020

2121
if url is not None and len(url) > 0:
2222
self.url = url
@@ -78,7 +78,10 @@ def get_result(self, url: str, query: dict, headers: dict) -> tuple:
7878
# Decode byte response to json
7979
err = response.json()
8080
if err is not None:
81-
return Error().config(err)
81+
error_code = err['error_code']
82+
error_message = err['error_message']
83+
raise ContentstackError('Server Error Code {} Message: {}'.format(error_code, error_message))
84+
# return Error().config(err)
8285

8386
except requests.RequestException as err:
8487
raise ConnectionError(err)

0 commit comments

Comments
 (0)