Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdria committed Aug 1, 2024
2 parents 3c8695f + 284c00b commit 3c836a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
13 changes: 0 additions & 13 deletions esignanywhere_python_client/esign_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,14 @@ def _handle_response_errors(
):
if response.status_code == 401:
raise exceptions.ESawUnauthorizedRequest(
message=response.text
and response.json().get("Message")
or f"Error with code {response.status_code}",
status_code=response.status_code,
method_name=method_name,
service_url=service_url,
request_data=request_data,
response=response,
)
else:
error_message = f"Error with code {response.status_code}"
if response.text:
error_id = response.json().get("ErrorId", "")
support_id = response.json().get("SupportId", "")
if error_id:
error_message = (
f"{response.text} [ErrorId: {error_id} SupportID: {support_id}]"
)
raise exceptions.ESawErrorResponse(
message=error_message,
status_code=response.status_code,
method_name=method_name,
service_url=service_url,
Expand Down Expand Up @@ -211,7 +199,6 @@ def create_and_send_envelope(
logger.info(f"Response from service_url : {service_url}: {response.json()}")
if "EnvelopeId" not in response.json().keys():
raise exceptions.ESawUnexpectedResponse(
message='Response has no attribute "EnvelopeId"',
method_name=(
inspect.currentframe().f_code.co_name # type: ignore
if inspect.currentframe()
Expand Down
10 changes: 4 additions & 6 deletions esignanywhere_python_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
class BaseAPIESawErrorResponse(Exception):
def __init__(
self,
message: str,
status_code: int,
service_url: str,
method_name: str,
Expand All @@ -16,7 +15,6 @@ def __init__(
**kwargs,
) -> None:
"""BaseAPIESawErrorResponse."""
self.message = message
self.status_code = status_code
self.service_url = service_url
self.method_name = method_name
Expand All @@ -34,10 +32,10 @@ def __init__(
self.response_data = "Unable to get response data"

def __str__(self):
return f"Status Code: {self.status_code} - Message: {self.message}"
return f"Status Code: {self.status_code}"

def __repr__(self):
return f"Status Code: {self.status_code} - Message: {self.message}"
return f"Status Code: {self.status_code}"


class ESawInvalidVersionError(Exception):
Expand All @@ -63,7 +61,7 @@ class ESawUnauthorizedRequest(BaseAPIESawErrorResponse):
class ESawUnexpectedResponse(BaseAPIESawErrorResponse):
def __str__(self):
return (
f"Unexpected Response from url {self.service_url}: {self.message}\n"
f"Unexpected Response from url {self.service_url}\n"
f"status_code : {self.status_code}\n"
f"method_name : {self.method_name}\n"
f"request_data : {str(self.request_data)}\n"
Expand All @@ -74,7 +72,7 @@ def __str__(self):
class ESawErrorResponse(BaseAPIESawErrorResponse):
def __str__(self):
return (
f"Error Response from url {self.service_url}: {self.message}\n"
f"Error Response from url {self.service_url}\n"
f"status_code : {self.status_code}\n"
f"method_name: {self.method_name}\n"
f"request_data : {str(self.request_data)}\n"
Expand Down

0 comments on commit 3c836a4

Please sign in to comment.