Skip to content

Commit

Permalink
Merge pull request #91 from duplocloud/client-errors-improvement
Browse files Browse the repository at this point in the history
update client error handling to print docstrings on error
  • Loading branch information
kferrone authored Aug 5, 2024
2 parents 2a3031d + a8b6f18 commit 0d3c532
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Updates
- changed handling of tenant arg in user resource
- add reference yaml for users
- changed client error handling to display docstrings on bad input


## [0.2.31] - 2024-07-29

Expand Down
11 changes: 10 additions & 1 deletion src/duplocloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import jsonpatch
import logging
import traceback
from datetime import datetime, timezone, timedelta
from urllib.parse import urlparse
from cachetools import cachedmethod, TTLCache
Expand Down Expand Up @@ -283,7 +284,15 @@ def __call__(self, resource: str=None, *args):
if not resource:
raise DuploError(str(self), 400)
r = self.load(resource)
d = r(*args)
try:
d = r(*args)
except TypeError:
if (r.__doc__):
raise DuploError(r.__doc__, 400)
else:
traceback.print_exc()
raise DuploError(f"No docstring found, error calling command {resource} : Traceback printed", 400)

if d is None:
return None
d = self.filter(d)
Expand Down

0 comments on commit 0d3c532

Please sign in to comment.