Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
esap-db-python-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
ESCAPE WP5
esap-db-python-client
Commits
07c601ee
Commit
07c601ee
authored
3 years ago
by
Pierre Chanial
Browse files
Options
Downloads
Patches
Plain Diff
Improve error handling of ESAP-DB server responses.
parent
701d2a59
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
esap_client/helpers.py
+8
-2
8 additions, 2 deletions
esap_client/helpers.py
esap_client/models/collections.py
+2
-2
2 additions, 2 deletions
esap_client/models/collections.py
with
10 additions
and
4 deletions
esap_client/helpers.py
+
8
−
2
View file @
07c601ee
"""
This module provides helper functions for the ESAP client.
"""
from
typing
import
Type
import
json
from
typing
import
Any
,
Type
from
requests
import
Response
from
tabulate
import
tabulate
...
...
@@ -18,7 +19,12 @@ def raise_for_status(response: Response) -> None:
else
:
cls
=
ESAPServerError
error
:
Any
try
:
error
=
response
.
json
()
except
json
.
JSONDecodeError
:
error
=
response
.
text
if
isinstance
(
error
,
dict
)
and
'
detail
'
in
error
:
error
=
error
[
'
detail
'
]
raise
cls
(
f
'
HTTP Error
{
response
.
status_code
}
:
{
error
}
'
)
...
...
This diff is collapsed.
Click to expand it.
esap_client/models/collections.py
+
2
−
2
View file @
07c601ee
...
...
@@ -19,7 +19,7 @@ def __init__(self, api: str, resource_cls: Type[T]) -> None:
"""
The `ResourceCollection` constructor.
"""
self
.
session
=
BasedSession
(
api
)
self
.
deserialize
:
Callable
[[
dict
],
T
]
=
resource_cls
.
deserialize
self
.
resource_type
=
type
(
resource_cls
)
.
__name__
self
.
resource_type
=
resource_cls
.
__name__
.
lower
()
def
__iter__
(
self
)
->
Iterator
[
T
]:
"""
Iterates through the resources in the collection.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment