Skip to content

Commit

Permalink
more conservative error handling (#15)
Browse files Browse the repository at this point in the history
* more conservative error handling

* Update version number for PyPI release

* Minor Update in README

Co-authored-by: ilsemaj <[email protected]> & @bbradshaw 🤝
  • Loading branch information
bbradshaw authored Dec 12, 2020
1 parent 2cd09b6 commit 2a11fe4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

Visit our [blog post on the API wrapper project](https://onfleet.com/blog/api-wrappers-explained/) to learn more about our initiatives. If you have any questions, please reach out to Onfleet by submitting an issue [here](https://github.com/onfleet/pyonfleet/issues) or contact [email protected]

STABLE VERSION: 1.1.1

## Table of Contents
- [Onfleet Python Wrapper](#onfleet-python-wrapper)
* [Table of Contents](#table-of-contents)
Expand Down
9 changes: 6 additions & 3 deletions onfleet/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ def __call__(self, headers=None, queryParams=None, id=None, body=None, **data):
return response.status_code if (method == "DELETE" or "complete" in url) else response.json()

error = json.loads(response.text)
error_code = error["message"]["error"]
error_message = error["message"]["message"]
error_request = error["message"]["request"]
try:
error_code = error["message"]["error"]
error_message = error["message"]["message"]
error_request = error["message"]["request"]
except TypeError:
raise HttpError(error.get("message"), response.status_code, None)
if (error_code <= 1108 and error_code >= 1100):
raise PermissionError(error_message, error_code, error_request)
elif (error_code == 2300):
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="pyonfleet",
version= "1.1.1",
version= "1.1.2",
author="James Li",
author_email="[email protected]",
description="Onfleet's Python API Wrapper Package",
Expand All @@ -27,4 +27,4 @@
"Operating System :: OS Independent",
],
license="LICENSE"
)
)

0 comments on commit 2a11fe4

Please sign in to comment.